| @@ 575-586 (lines=12) @@ | ||
| 572 | * |
|
| 573 | * @return Stringy Object with its $str being the first $n chars |
|
| 574 | */ |
|
| 575 | public function first($n) |
|
| 576 | { |
|
| 577 | $stringy = static::create($this->str, $this->encoding); |
|
| 578 | ||
| 579 | if ($n < 0) { |
|
| 580 | $stringy->str = ''; |
|
| 581 | } else { |
|
| 582 | return $stringy->substr(0, $n); |
|
| 583 | } |
|
| 584 | ||
| 585 | return $stringy; |
|
| 586 | } |
|
| 587 | ||
| 588 | /** |
|
| 589 | * Returns the encoding used by the Stringy object. |
|
| @@ 963-974 (lines=12) @@ | ||
| 960 | * |
|
| 961 | * @return Stringy Object with its $str being the last $n chars |
|
| 962 | */ |
|
| 963 | public function last($n) |
|
| 964 | { |
|
| 965 | $stringy = static::create($this->str, $this->encoding); |
|
| 966 | ||
| 967 | if ($n <= 0) { |
|
| 968 | $stringy->str = ''; |
|
| 969 | } else { |
|
| 970 | return $stringy->substr(-$n); |
|
| 971 | } |
|
| 972 | ||
| 973 | return $stringy; |
|
| 974 | } |
|
| 975 | ||
| 976 | /** |
|
| 977 | * Splits on newlines and carriage returns, returning an array of Stringy |
|