Skip to content

Commit b9046ca

Browse files
authored
Allow str_limit to accept null (#11)
Co-authored-by: onairmarc <[email protected]>
1 parent 2146e4e commit b9046ca

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ c0c6bf6fb1c3ad80ff54b7420853ecc9096ee576
55
d637c653da4a72e3b2b1132c1f0a4af3e0135387
66
de3cddf99b38b4504132eb7449c2b7a20aee5cc3
77
ad93f3bac4b6e6937e0e9a1a709afe31e66c5f54
8+
6c08e6e8b8f13e2ef4526bb18edbac2b136d3261

src/ObjectHelpers/str_helpers.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,12 @@ function stringify(mixed $str): string
4747
}
4848

4949
if (!function_exists('str_limit')) {
50-
function str_limit(string $str, int $limit = 100): string
50+
function str_limit(?string $str = null, int $limit = 100): ?string
5151
{
52+
if ($str == null) {
53+
return null;
54+
}
55+
5256
return Str::limit($str, $limit);
5357
}
5458
}

0 commit comments

Comments
 (0)