| @@ 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. |
|
| @@ 939-950 (lines=12) @@ | ||
| 936 | * |
|
| 937 | * @return Stringy Object with its $str being the last $n chars |
|
| 938 | */ |
|
| 939 | public function last($n) |
|
| 940 | { |
|
| 941 | $stringy = static::create($this->str, $this->encoding); |
|
| 942 | ||
| 943 | if ($n <= 0) { |
|
| 944 | $stringy->str = ''; |
|
| 945 | } else { |
|
| 946 | return $stringy->substr(-$n); |
|
| 947 | } |
|
| 948 | ||
| 949 | return $stringy; |
|
| 950 | } |
|
| 951 | ||
| 952 | /** |
|
| 953 | * Splits on newlines and carriage returns, returning an array of Stringy |
|