| @@ 2438-2461 (lines=24) @@ | ||
| 2435 | * |
|
| 2436 | * @return static |
|
| 2437 | */ |
|
| 2438 | public function afterFirst($separator) |
|
| 2439 | { |
|
| 2440 | if ($separator === '') { |
|
| 2441 | return static::create(''); |
|
| 2442 | } |
|
| 2443 | ||
| 2444 | if ($this->str === '') { |
|
| 2445 | return static::create(''); |
|
| 2446 | } |
|
| 2447 | ||
| 2448 | if (($offset = $this->indexOf($separator)) === false) { |
|
| 2449 | return static::create(''); |
|
| 2450 | } |
|
| 2451 | ||
| 2452 | return static::create( |
|
| 2453 | UTF8::substr( |
|
| 2454 | $this->str, |
|
| 2455 | $offset + UTF8::strlen($separator, $this->encoding), |
|
| 2456 | null, |
|
| 2457 | $this->encoding |
|
| 2458 | ), |
|
| 2459 | $this->encoding |
|
| 2460 | ); |
|
| 2461 | } |
|
| 2462 | ||
| 2463 | /** |
|
| 2464 | * Gets the substring after the first occurrence of a separator. |
|
| @@ 2471-2494 (lines=24) @@ | ||
| 2468 | * |
|
| 2469 | * @return static |
|
| 2470 | */ |
|
| 2471 | public function afterFirstIgnoreCase($separator) |
|
| 2472 | { |
|
| 2473 | if ($separator === '') { |
|
| 2474 | return static::create(''); |
|
| 2475 | } |
|
| 2476 | ||
| 2477 | if ($this->str === '') { |
|
| 2478 | return static::create(''); |
|
| 2479 | } |
|
| 2480 | ||
| 2481 | if (($offset = $this->indexOfIgnoreCase($separator)) === false) { |
|
| 2482 | return static::create(''); |
|
| 2483 | } |
|
| 2484 | ||
| 2485 | return static::create( |
|
| 2486 | UTF8::substr( |
|
| 2487 | $this->str, |
|
| 2488 | $offset + UTF8::strlen($separator, $this->encoding), |
|
| 2489 | null, |
|
| 2490 | $this->encoding |
|
| 2491 | ), |
|
| 2492 | $this->encoding |
|
| 2493 | ); |
|
| 2494 | } |
|
| 2495 | ||
| 2496 | /** |
|
| 2497 | * Gets the substring after the last occurrence of a separator. |
|
| @@ 2504-2528 (lines=25) @@ | ||
| 2501 | * |
|
| 2502 | * @return static |
|
| 2503 | */ |
|
| 2504 | public function afterLastIgnoreCase($separator) |
|
| 2505 | { |
|
| 2506 | if ($separator === '') { |
|
| 2507 | return static::create(''); |
|
| 2508 | } |
|
| 2509 | ||
| 2510 | if ($this->str === '') { |
|
| 2511 | return static::create(''); |
|
| 2512 | } |
|
| 2513 | ||
| 2514 | $offset = $this->indexOfLastIgnoreCase($separator); |
|
| 2515 | if ($offset === false) { |
|
| 2516 | return static::create('', $this->encoding); |
|
| 2517 | } |
|
| 2518 | ||
| 2519 | return static::create( |
|
| 2520 | UTF8::substr( |
|
| 2521 | $this->str, |
|
| 2522 | $offset + UTF8::strlen($separator, $this->encoding), |
|
| 2523 | null, |
|
| 2524 | $this->encoding |
|
| 2525 | ), |
|
| 2526 | $this->encoding |
|
| 2527 | ); |
|
| 2528 | } |
|
| 2529 | ||
| 2530 | /** |
|
| 2531 | * Gets the substring after the last occurrence of a separator. |
|
| @@ 2538-2562 (lines=25) @@ | ||
| 2535 | * |
|
| 2536 | * @return static |
|
| 2537 | */ |
|
| 2538 | public function afterLast($separator) |
|
| 2539 | { |
|
| 2540 | if ($separator === '') { |
|
| 2541 | return static::create(''); |
|
| 2542 | } |
|
| 2543 | ||
| 2544 | if ($this->str === '') { |
|
| 2545 | return static::create(''); |
|
| 2546 | } |
|
| 2547 | ||
| 2548 | $offset = $this->indexOfLast($separator); |
|
| 2549 | if ($offset === false) { |
|
| 2550 | return static::create('', $this->encoding); |
|
| 2551 | } |
|
| 2552 | ||
| 2553 | return static::create( |
|
| 2554 | UTF8::substr( |
|
| 2555 | $this->str, |
|
| 2556 | $offset + UTF8::strlen($separator, $this->encoding), |
|
| 2557 | null, |
|
| 2558 | $this->encoding |
|
| 2559 | ), |
|
| 2560 | $this->encoding |
|
| 2561 | ); |
|
| 2562 | } |
|
| 2563 | ||
| 2564 | /** |
|
| 2565 | * Gets the substring before the first occurrence of a separator. |
|
| @@ 2572-2596 (lines=25) @@ | ||
| 2569 | * |
|
| 2570 | * @return static |
|
| 2571 | */ |
|
| 2572 | public function beforeFirst($separator) |
|
| 2573 | { |
|
| 2574 | if ($separator === '') { |
|
| 2575 | return static::create(''); |
|
| 2576 | } |
|
| 2577 | ||
| 2578 | if ($this->str === '') { |
|
| 2579 | return static::create(''); |
|
| 2580 | } |
|
| 2581 | ||
| 2582 | $offset = $this->indexOf($separator); |
|
| 2583 | if ($offset === false) { |
|
| 2584 | return static::create('', $this->encoding); |
|
| 2585 | } |
|
| 2586 | ||
| 2587 | return static::create( |
|
| 2588 | UTF8::substr( |
|
| 2589 | $this->str, |
|
| 2590 | 0, |
|
| 2591 | $offset, |
|
| 2592 | $this->encoding |
|
| 2593 | ), |
|
| 2594 | $this->encoding |
|
| 2595 | ); |
|
| 2596 | } |
|
| 2597 | ||
| 2598 | /** |
|
| 2599 | * Gets the substring before the first occurrence of a separator. |
|
| @@ 2606-2630 (lines=25) @@ | ||
| 2603 | * |
|
| 2604 | * @return static |
|
| 2605 | */ |
|
| 2606 | public function beforeFirstIgnoreCase($separator) |
|
| 2607 | { |
|
| 2608 | if ($separator === '') { |
|
| 2609 | return static::create(''); |
|
| 2610 | } |
|
| 2611 | ||
| 2612 | if ($this->str === '') { |
|
| 2613 | return static::create(''); |
|
| 2614 | } |
|
| 2615 | ||
| 2616 | $offset = $this->indexOfIgnoreCase($separator); |
|
| 2617 | if ($offset === false) { |
|
| 2618 | return static::create('', $this->encoding); |
|
| 2619 | } |
|
| 2620 | ||
| 2621 | return static::create( |
|
| 2622 | UTF8::substr( |
|
| 2623 | $this->str, |
|
| 2624 | 0, |
|
| 2625 | $offset, |
|
| 2626 | $this->encoding |
|
| 2627 | ), |
|
| 2628 | $this->encoding |
|
| 2629 | ); |
|
| 2630 | } |
|
| 2631 | ||
| 2632 | /** |
|
| 2633 | * Gets the substring before the last occurrence of a separator. |
|
| @@ 2640-2664 (lines=25) @@ | ||
| 2637 | * |
|
| 2638 | * @return static |
|
| 2639 | */ |
|
| 2640 | public function beforeLast($separator) |
|
| 2641 | { |
|
| 2642 | if ($separator === '') { |
|
| 2643 | return static::create(''); |
|
| 2644 | } |
|
| 2645 | ||
| 2646 | if ($this->str === '') { |
|
| 2647 | return static::create(''); |
|
| 2648 | } |
|
| 2649 | ||
| 2650 | $offset = $this->indexOfLast($separator); |
|
| 2651 | if ($offset === false) { |
|
| 2652 | return static::create('', $this->encoding); |
|
| 2653 | } |
|
| 2654 | ||
| 2655 | return static::create( |
|
| 2656 | UTF8::substr( |
|
| 2657 | $this->str, |
|
| 2658 | 0, |
|
| 2659 | $offset, |
|
| 2660 | $this->encoding |
|
| 2661 | ), |
|
| 2662 | $this->encoding |
|
| 2663 | ); |
|
| 2664 | } |
|
| 2665 | ||
| 2666 | /** |
|
| 2667 | * Gets the substring before the last occurrence of a separator. |
|
| @@ 2674-2698 (lines=25) @@ | ||
| 2671 | * |
|
| 2672 | * @return static |
|
| 2673 | */ |
|
| 2674 | public function beforeLastIgnoreCase($separator) |
|
| 2675 | { |
|
| 2676 | if ($separator === '') { |
|
| 2677 | return static::create(''); |
|
| 2678 | } |
|
| 2679 | ||
| 2680 | if ($this->str === '') { |
|
| 2681 | return static::create(''); |
|
| 2682 | } |
|
| 2683 | ||
| 2684 | $offset = $this->indexOfLastIgnoreCase($separator); |
|
| 2685 | if ($offset === false) { |
|
| 2686 | return static::create('', $this->encoding); |
|
| 2687 | } |
|
| 2688 | ||
| 2689 | return static::create( |
|
| 2690 | UTF8::substr( |
|
| 2691 | $this->str, |
|
| 2692 | 0, |
|
| 2693 | $offset, |
|
| 2694 | $this->encoding |
|
| 2695 | ), |
|
| 2696 | $this->encoding |
|
| 2697 | ); |
|
| 2698 | } |
|
| 2699 | ||
| 2700 | /** |
|
| 2701 | * Returns the string with the first letter of each word capitalized, |
|