Skip to content

Commit deb9197

Browse files
authored
Create Str::empty() (#29)
Co-authored-by: onairmarc <[email protected]>
1 parent 7b6d7ef commit deb9197

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.git-blame-ignore-revs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ d521d82e9b14a5f411f3492529800c6b39f17740
1515
11b88b5f8641574fc93d2a4f443aeaf819381c91
1616
f74b50a0c5a93e2042dd0899f67dc0d77d9f37b2
1717
9e90f1089ce7ad5f2e9e3396c5764687690c96bb
18+
68d26b0bcc009757d3a8c4b4aca534522832a35b

src/Objects/Str.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ public static function guid(): string
4040
return Str::uuid()->toString();
4141
}
4242

43+
public static function empty(): string
44+
{
45+
return '';
46+
}
47+
4348
public static function toString(mixed $value): string
4449
{
4550
return (string) $value;

tests/Unit/StringTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,14 @@
2525
->and(is_string($result))->toBeTrue();
2626
});
2727

28+
test('empty method returns an empty string', function () {
29+
$value = 123;
30+
31+
$result = Str::empty();
32+
33+
expect($result)->toEqual('');
34+
});
35+
2836
test('maxLength method limits the length of a string', function () {
2937
$value = 'Hello World';
3038

0 commit comments

Comments
 (0)