| @@ 550-561 (lines=12) @@ | ||
| 547 | * |
|
| 548 | * @return Stringy Object with its $str being the first $n chars |
|
| 549 | */ |
|
| 550 | public function first($n) |
|
| 551 | { |
|
| 552 | $stringy = static::create($this->str, $this->encoding); |
|
| 553 | ||
| 554 | if ($n < 0) { |
|
| 555 | $stringy->str = ''; |
|
| 556 | } else { |
|
| 557 | return $stringy->substr(0, $n); |
|
| 558 | } |
|
| 559 | ||
| 560 | return $stringy; |
|
| 561 | } |
|
| 562 | ||
| 563 | /** |
|
| 564 | * Returns the encoding used by the Stringy object. |
|
| @@ 914-925 (lines=12) @@ | ||
| 911 | * |
|
| 912 | * @return Stringy Object with its $str being the last $n chars |
|
| 913 | */ |
|
| 914 | public function last($n) |
|
| 915 | { |
|
| 916 | $stringy = static::create($this->str, $this->encoding); |
|
| 917 | ||
| 918 | if ($n <= 0) { |
|
| 919 | $stringy->str = ''; |
|
| 920 | } else { |
|
| 921 | return $stringy->substr(-$n); |
|
| 922 | } |
|
| 923 | ||
| 924 | return $stringy; |
|
| 925 | } |
|
| 926 | ||
| 927 | /** |
|
| 928 | * Splits on newlines and carriage returns, returning an array of Stringy |
|