Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Illuminate/Support/Stringable.php
Original file line number Diff line number Diff line change
Expand Up @@ -293,13 +293,13 @@ public function doesntEndWith($needles)
/**
* Determine if the string is an exact match with the given value.
*
* @param \Illuminate\Support\Stringable|string $value
* @param BaseStringable|string $value
* @return bool
*/
public function exactly($value)
{
if ($value instanceof Stringable) {
$value = $value->toString();
if ($value instanceof BaseStringable) {
$value = (string) $value;
}

return $this->value === $value;
Expand Down
8 changes: 8 additions & 0 deletions tests/Support/SupportStringableTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1477,6 +1477,14 @@ public function testExactly()
$this->assertFalse($this->stringable('Foo')->exactly('foo'));
$this->assertFalse($this->stringable('[]')->exactly([]));
$this->assertFalse($this->stringable('0')->exactly(0));
$this->assertTrue($this->stringable('foo')->exactly(new class() implements \Stringable
{
public function __toString(): string
{
return 'foo';
}
}));
$this->assertFalse($this->stringable('foo')->exactly(new class() {}));
}

public function testToInteger()
Expand Down
Loading