removeSuffix() public static method

Example: $string = 'JohnSnow'; $withoutSuffix = Strings::removeSuffix($string, 'Snow'); Result: John
public static removeSuffix ( string $string, string $suffix ) : string
$string string
$suffix string
return string
示例#1
0
 public function getViewName()
 {
     $class = Strings::underscoreToCamelCase($this->controller);
     if (Strings::endsWith($class, 'Controller')) {
         return Strings::removeSuffix($class, 'Controller');
     }
     return $class;
 }
示例#2
0
 /**
  * @test
  */
 public function shouldRemoveSuffix()
 {
     //given
     $string = 'JohnSnow';
     //when
     $withoutSuffix = Strings::removeSuffix($string, 'Snow');
     //then
     $this->assertEquals('John', $withoutSuffix);
 }