$string = 'prefixRest'; $withoutPrefix = Strings::removePrefix($string, 'prefix');
Rest
public static function removePrefix($string, $prefix) { if (self::startsWith($string, $prefix)) { return substr($string, mb_strlen($prefix)); } return $string; }
/** * @test */ public function shouldRemovePrefixWhenStringIsEqualToPrefix() { //given $string = 'prefix'; //when $withoutPrefix = Strings::removePrefix($string, 'prefix'); //then $this->assertEquals('', $withoutPrefix); }