@@ 2275-2290 (lines=16) @@ | ||
2272 | * |
|
2273 | * @return Stringy |
|
2274 | */ |
|
2275 | public function afterFirst($separator) |
|
2276 | { |
|
2277 | if (($offset = $this->indexOf($separator)) === false) { |
|
2278 | return static::create(''); |
|
2279 | } |
|
2280 | ||
2281 | return static::create( |
|
2282 | UTF8::substr( |
|
2283 | $this->str, |
|
2284 | $offset + UTF8::strlen($separator, $this->encoding), |
|
2285 | null, |
|
2286 | $this->encoding |
|
2287 | ), |
|
2288 | $this->encoding |
|
2289 | ); |
|
2290 | } |
|
2291 | ||
2292 | /** |
|
2293 | * Gets the substring after the last occurrence of a separator. |
|
@@ 2326-2342 (lines=17) @@ | ||
2323 | * |
|
2324 | * @return Stringy |
|
2325 | */ |
|
2326 | public function beforeFirst($separator) |
|
2327 | { |
|
2328 | $offset = $this->indexOf($separator); |
|
2329 | if ($offset === false) { |
|
2330 | return static::create('', $this->encoding); |
|
2331 | } |
|
2332 | ||
2333 | return static::create( |
|
2334 | UTF8::substr( |
|
2335 | $this->str, |
|
2336 | 0, |
|
2337 | $offset, |
|
2338 | $this->encoding |
|
2339 | ), |
|
2340 | $this->encoding |
|
2341 | ); |
|
2342 | } |
|
2343 | ||
2344 | /** |
|
2345 | * Gets the substring before the last occurrence of a separator. |
|
@@ 2352-2368 (lines=17) @@ | ||
2349 | * |
|
2350 | * @return Stringy |
|
2351 | */ |
|
2352 | public function beforeLast($separator) |
|
2353 | { |
|
2354 | $offset = $this->indexOfLast($separator); |
|
2355 | if ($offset === false) { |
|
2356 | return static::create('', $this->encoding); |
|
2357 | } |
|
2358 | ||
2359 | return static::create( |
|
2360 | UTF8::substr( |
|
2361 | $this->str, |
|
2362 | 0, |
|
2363 | $offset, |
|
2364 | $this->encoding |
|
2365 | ), |
|
2366 | $this->encoding |
|
2367 | ); |
|
2368 | } |
|
2369 | ||
2370 | /** |
|
2371 | * Returns the string with the first letter of each word capitalized, |