| Conditions | 3 |
| Paths | 3 |
| Total Lines | 15 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 60 | public static function fromString(string $sections): self |
||
| 61 | { |
||
| 62 | $result = preg_match('/^\[(.*?)\]$/', $sections, $matches); |
||
| 63 | if ($result !== 1) { |
||
| 64 | throw new \InvalidArgumentException('No section list'); |
||
| 65 | } |
||
| 66 | |||
| 67 | $sectionList = new self(array_filter(explode(' ', $matches[1]))); |
||
| 68 | |||
| 69 | if (empty($sectionList->sections)) { |
||
| 70 | $sectionList->forceBrackets = true; |
||
| 71 | } |
||
| 72 | |||
| 73 | return $sectionList; |
||
| 74 | } |
||
| 75 | |||
| 76 | } |