/** * @param string $message * @param string$replace * @return string */ protected function parseMessage($message, $replace = '') { if ($replace) { $message = Str::replaceFirst($replace, '', $message); } return trim($message); }
/** * @param string $newPath * @return self */ public function replacePath($newPath) { if (!$this->url) { return $newPath; } $this->url = Str::replaceFirst($this->getPath(), $newPath, $this->url); return $this; }
/** * @deprecated */ public static function replaceFirst($search, $replace, $subject) { trigger_error(self::NOTICE, E_USER_DEPRECATED); return Str::replaceFirst($search, $replace, $subject); }
/** * Gets the Classname to generate from the called class like * MakeDataObjectCommand => DataObject class * MakeFormCommand => Form class. * * @return string */ public function getCommandClass() { $class = get_class($this); $class = Str::replaceFirst('Make', '', $class); $class = Str::replaceLast('Command', '', $class); return $class; }
public function testReplaceFirst() { $this->assertEquals('HEY two tree one', Str::replaceFirst('one', 'HEY', 'one two tree one')); $this->assertEquals('HEYone two tree', Str::replaceFirst('one', 'HEY', 'oneone two tree')); $this->assertEquals('one two tree', Str::replaceFirst('nine', 'HEY', 'one two tree')); }