/** * @param $value * @return HString */ public function remove($value) { $key = $this->hString->locate($value); $startString = $this->hString->slice(0, $key); $endString = $this->hString->slice($key + 1); return $startString->insert($endString); }
/** * @param HString &$hString * @param callable $func */ public static function walk(HString &$hString, callable $func) { $size = $hString->count(); for ($i = 0; $i < $size; $i++) { $hString[$i] = $func($hString[$i], $i); } }
/** * @param $value * @return int * @throws ElementNotFoundException */ public function locate($value) { if ($this->hString->contains($value)) { return mb_strpos($this->hString, (string) $value, null, $this->hString->getEncoding()); } throw new ElementNotFoundException($value); }
/** * @param $value * @return int * @throws ElementNotFoundException */ public function locate($value) { if ($this->hString->contains($value)) { return strpos($this->hString, (string) $value); } throw new ElementNotFoundException($value); }
private function getSuffix($start) { return mb_substr($this->hString, $start + 1, $this->hString->count() - $start, $this->hString->getEncoding()); }
/** * @param HString $hString */ public function __construct(HString $hString) { $this->str = $hString->toString(); }
private function getSuffix($key) { $start = $key >= 0 ? $key : $this->hString->count() + $key; $length = $key >= 0 ? $this->hString->count() : $this->hString->count() + $key; return mb_substr($this->hString, $start, $length, $this->hString->getEncoding()); }
public function __construct(HString $hString) { $this->str = $hString->toString(); $this->encoding = $hString->getEncoding(); }