Conditions | 3 |
Paths | 3 |
Total Lines | 20 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
16 | public static function nowdoc(string $str) : string |
||
17 | { |
||
18 | $lines = preg_split('/\\n/', $str); |
||
19 | |||
20 | if (count($lines) <= 2) { |
||
|
|||
21 | return ''; |
||
22 | } |
||
23 | |||
24 | // Toss out the first and last lines. |
||
25 | $lines = array_slice($lines, 1, count($lines) - 2); |
||
26 | |||
27 | // take the tabs form the first line, and subtract them from all lines |
||
28 | $matches = []; |
||
29 | preg_match('/(^\s+)/', $lines[1], $matches); |
||
30 | |||
31 | for ($i = 0; $i < count($lines); $i++) { |
||
32 | $lines[$i] = str_replace($matches[0], '', $lines[$i]); |
||
33 | } |
||
34 | |||
35 | return implode("\n", $lines); |
||
36 | } |
||
38 |