| @@ 92-104 (lines=13) @@ | ||
| 89 | * |
|
| 90 | * @return int |
|
| 91 | */ |
|
| 92 | public function position(string $needle, int $offset = 0): int |
|
| 93 | { |
|
| 94 | $position = mb_strpos($this->value, $needle, $offset); |
|
| 95 | ||
| 96 | if ($position === false) { |
|
| 97 | throw new SubstringException(sprintf( |
|
| 98 | 'Substring "%s" not found', |
|
| 99 | $needle |
|
| 100 | )); |
|
| 101 | } |
|
| 102 | ||
| 103 | return (int) $position; |
|
| 104 | } |
|
| 105 | ||
| 106 | /** |
|
| 107 | * Replace all occurences of the search string with the replacement one |
|
| @@ 102-114 (lines=13) @@ | ||
| 99 | * |
|
| 100 | * @return int |
|
| 101 | */ |
|
| 102 | public function pos(string $needle, int $offset = 0): int |
|
| 103 | { |
|
| 104 | $position = mb_strpos($this->value, $needle, $offset); |
|
| 105 | ||
| 106 | if ($position === false) { |
|
| 107 | throw new SubstringException(sprintf( |
|
| 108 | 'Substring "%s" not found', |
|
| 109 | $needle |
|
| 110 | )); |
|
| 111 | } |
|
| 112 | ||
| 113 | return (int) $position; |
|
| 114 | } |
|
| 115 | ||
| 116 | /** |
|
| 117 | * Replace all occurences of the search string with the replacement one |
|