$string = 'JohnSnow'; $withoutSuffix = Strings::removeSuffix($string, 'Snow');
John
public function getViewName() { $class = Strings::underscoreToCamelCase($this->controller); if (Strings::endsWith($class, 'Controller')) { return Strings::removeSuffix($class, 'Controller'); } return $class; }
/** * @test */ public function shouldRemoveSuffix() { //given $string = 'JohnSnow'; //when $withoutSuffix = Strings::removeSuffix($string, 'Snow'); //then $this->assertEquals('John', $withoutSuffix); }