| Total Complexity | 6 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 14 | class ExampleTag extends AbstractTag |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * Process a notation. |
||
| 18 | * |
||
| 19 | * @param array $notations |
||
| 20 | * @param string $value |
||
| 21 | * @return array |
||
| 22 | */ |
||
| 23 | 9 | public function process(array $notations, string $value): array |
|
| 24 | { |
||
| 25 | 9 | $regexp = '/^(?<location>(?:[^"]\S*|"[^"]+"))(?:\s*(?<start_line>\d+)' |
|
| 26 | 9 | . '(?:\s*(?<number_of_lines>\d+))?)?(?:\s*(?<description>.+))?/'; |
|
| 27 | |||
| 28 | 9 | if (!preg_match($regexp, $value, $matches)) { |
|
| 29 | 2 | throw new PhpdocException("Failed to parse '@{$this->name} $value': invalid syntax"); |
|
| 30 | } |
||
| 31 | |||
| 32 | 7 | $this->normalizeValues($matches); |
|
| 33 | 7 | $matches = array_only($matches, ['location', 'start_line', 'number_of_lines', 'description']); |
|
| 34 | |||
| 35 | 7 | $notations[$this->name] = $matches; |
|
| 36 | |||
| 37 | 7 | return $notations; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Normalize parsed values |
||
| 42 | * |
||
| 43 | * @param array $values |
||
| 44 | */ |
||
| 45 | 7 | protected function normalizeValues(array &$values): void |
|
| 58 | } |
||
| 59 | } |
||
| 62 |