| @@ 38-55 (lines=18) @@ | ||
| 35 | * @param object $bucket |
|
| 36 | * @return string[] |
|
| 37 | */ |
|
| 38 | private function getLines($bucket) |
|
| 39 | { |
|
| 40 | $lines = preg_split( |
|
| 41 | '/([\r\n]+)/', |
|
| 42 | $bucket->data, |
|
| 43 | -1, |
|
| 44 | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 45 | ); |
|
| 46 | if (!empty($this->leftover)) { |
|
| 47 | $lines[0] = $this->leftover . $lines[0]; |
|
| 48 | $this->leftover = ''; |
|
| 49 | } |
|
| 50 | $last = end($lines); |
|
| 51 | if ($last[strlen($last) - 1] !== "\n") { |
|
| 52 | $this->leftover = array_pop($lines); |
|
| 53 | } |
|
| 54 | return $lines; |
|
| 55 | } |
|
| 56 | ||
| 57 | /** |
|
| 58 | * Filters the lines in the passed $lines array, returning a concatenated |
|
| @@ 40-57 (lines=18) @@ | ||
| 37 | * @param object $bucket |
|
| 38 | * @return string[] |
|
| 39 | */ |
|
| 40 | private function getLines($bucket) |
|
| 41 | { |
|
| 42 | $lines = preg_split( |
|
| 43 | '/([^\r\n]+[\r\n]+)/', |
|
| 44 | $bucket->data, |
|
| 45 | -1, |
|
| 46 | PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY |
|
| 47 | ); |
|
| 48 | if (!empty($this->leftover)) { |
|
| 49 | $lines[0] = $this->leftover . $lines[0]; |
|
| 50 | $this->leftover = ''; |
|
| 51 | } |
|
| 52 | $last = end($lines); |
|
| 53 | if ($last[strlen($last) - 1] !== "\n") { |
|
| 54 | $this->leftover = array_pop($lines); |
|
| 55 | } |
|
| 56 | return $lines; |
|
| 57 | } |
|
| 58 | ||
| 59 | /** |
|
| 60 | * Returns true if the passed $line is empty or matches the beginning header |
|