Skip to content

Commit 1aaa71d

Browse files
committed
Avoid object instantiation
1 parent af6f9a9 commit 1aaa71d

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Collection/Primitive/Boolean.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
namespace MichaelRubel\ValueObjects\Collection\Primitive;
1414

15-
use Illuminate\Support\Stringable;
15+
use Illuminate\Support\Str;
1616
use InvalidArgumentException;
1717
use MichaelRubel\ValueObjects\ValueObject;
1818

@@ -83,11 +83,9 @@ public function value(): bool
8383
*/
8484
protected function handleNonBoolean(int|string $value): void
8585
{
86-
$string = new Stringable($value);
87-
8886
$this->value = match (true) {
89-
$string->contains($this->trueValues, ignoreCase: true) => true,
90-
$string->contains($this->falseValues, ignoreCase: true) => false,
87+
Str::contains($value, $this->trueValues, ignoreCase: true) => true,
88+
Str::contains($value, $this->falseValues, ignoreCase: true) => false,
9189
default => throw new InvalidArgumentException('Invalid boolean.'),
9290
};
9391
}

0 commit comments

Comments
 (0)