1
0
mirror of https://github.com/danielstjules/Stringy.git synced 2025-09-02 01:22:37 +02:00

Added lines

This commit is contained in:
Daniel St. Jules
2015-07-25 22:19:36 -07:00
parent cce314f4a5
commit b9cf4b6ae3
3 changed files with 63 additions and 0 deletions

View File

@@ -215,6 +215,22 @@ class Stringy implements \Countable, \IteratorAggregate, \ArrayAccess
return $chars;
}
/**
* Splits on newlines and carriage returns, returning an array of Stringy
* objects corresponding to the lines in the string.
*
* @return Stringy[] An array of Stringy objects
*/
public function lines()
{
$array = mb_split('[\r\n]{1,2}', $this->str);
for ($i = 0; $i < count($array); $i++) {
$array[$i] = static::create($array[$i], $this->encoding);
}
return $array;
}
/**
* Converts the first character of the supplied string to upper case.
*