Skip to content

Commit

Permalink
[8.x] Add classBasename() method to Stringable (#35219)
Browse files Browse the repository at this point in the history
* Add classBasename() method to Stringable

* Add test
  • Loading branch information
jameslkingsley committed Nov 13, 2020
1 parent be56c6f commit c6c67bd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Illuminate/Support/Stringable.php
Expand Up @@ -82,6 +82,16 @@ public function basename($suffix = '')
{
return new static(basename($this->value, $suffix));
}

/**
* Get the basename of the class path.
*
* @return static
*/
public function classBasename()
{
return new static(class_basename($this->value));
}

/**
* Get the portion of a string before the first occurrence of a given value.
Expand Down
8 changes: 8 additions & 0 deletions tests/Support/SupportStringableTest.php
Expand Up @@ -16,6 +16,14 @@ protected function stringable($string = '')
{
return new Stringable($string);
}

public function testClassBasename()
{
$this->assertEquals(
class_basename(static::class),
$this->stringable(static::class)->classBasename()
);
}

public function testIsAscii()
{
Expand Down

0 comments on commit c6c67bd

Please sign in to comment.