Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[8.x] Add classBasename() method to Stringable #35219

Merged
merged 2 commits into from Nov 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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