Conditions | 6 |
Paths | 2 |
Total Lines | 27 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
38 | protected static function extractTypeFromBody(string $body) : array |
||
39 | { |
||
40 | $type = ''; |
||
41 | $nestingLevel = 0; |
||
42 | for ($i = 0; $i < strlen($body); $i++) { |
||
43 | $character = $body[$i]; |
||
44 | |||
45 | if (trim($character) === '' && $nestingLevel === 0) { |
||
46 | break; |
||
47 | } |
||
48 | |||
49 | $type .= $character; |
||
50 | if (in_array($character, ['<', '(', '[', '{'])) { |
||
51 | $nestingLevel++; |
||
52 | continue; |
||
53 | } |
||
54 | |||
55 | if (in_array($character, ['>', ')', ']', '}'])) { |
||
56 | $nestingLevel--; |
||
57 | continue; |
||
58 | } |
||
59 | } |
||
60 | |||
61 | $description = trim(substr($body, strlen($type))); |
||
62 | |||
63 | return [$type, $description]; |
||
64 | } |
||
65 | } |
||
66 |