示例#1
0
 /**
  * @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);
 }
示例#2
0
 /**
  * @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);
     }
 }
示例#3
0
 /**
  * @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);
 }
示例#4
0
 /**
  * @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);
 }
示例#5
0
 private function getSuffix($start)
 {
     return mb_substr($this->hString, $start + 1, $this->hString->count() - $start, $this->hString->getEncoding());
 }
示例#6
0
 /**
  * @param HString $hString
  */
 public function __construct(HString $hString)
 {
     $this->str = $hString->toString();
 }
示例#7
0
 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());
 }
示例#8
0
 public function __construct(HString $hString)
 {
     $this->str = $hString->toString();
     $this->encoding = $hString->getEncoding();
 }