| @@ 2256-2272 (lines=17) @@ | ||
| 2253 | * |
|
| 2254 | * @return Stringy |
|
| 2255 | */ |
|
| 2256 | public function beforeFirst($separator) |
|
| 2257 | { |
|
| 2258 | $offset = $this->indexOf($separator); |
|
| 2259 | if ($offset === false) { |
|
| 2260 | return static::create(''); |
|
| 2261 | } |
|
| 2262 | ||
| 2263 | return static::create( |
|
| 2264 | UTF8::substr( |
|
| 2265 | $this->str, |
|
| 2266 | 0, |
|
| 2267 | $offset, |
|
| 2268 | $this->encoding |
|
| 2269 | ), |
|
| 2270 | $this->encoding |
|
| 2271 | ); |
|
| 2272 | } |
|
| 2273 | ||
| 2274 | /** |
|
| 2275 | * Gets the substring before the last occurrence of a separator. |
|
| @@ 2282-2298 (lines=17) @@ | ||
| 2279 | * |
|
| 2280 | * @return Stringy |
|
| 2281 | */ |
|
| 2282 | public function beforeLast($separator) |
|
| 2283 | { |
|
| 2284 | $offset = $this->indexOfLast($separator); |
|
| 2285 | if ($offset === false) { |
|
| 2286 | return static::create(''); |
|
| 2287 | } |
|
| 2288 | ||
| 2289 | return static::create( |
|
| 2290 | UTF8::substr( |
|
| 2291 | $this->str, |
|
| 2292 | 0, |
|
| 2293 | $offset, |
|
| 2294 | $this->encoding |
|
| 2295 | ), |
|
| 2296 | $this->encoding |
|
| 2297 | ); |
|
| 2298 | } |
|
| 2299 | } |
|
| 2300 | ||