Conditions | 5 |
Paths | 10 |
Total Lines | 22 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Changes | 10 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
36 | public function interpret(string $input): string |
||
37 | { |
||
38 | $num = 0; |
||
39 | $output = []; |
||
40 | |||
41 | if (preg_match('~[0-9]+~', $input, $match)) { |
||
42 | $num = $match[0] - 1; |
||
43 | } |
||
44 | |||
45 | if (!array_key_exists($num, $this->registryData)) { |
||
46 | throw new \InvalidArgumentException("Element $num does not exist in the registry"); |
||
47 | } |
||
48 | |||
49 | if (strpos($input, 'author') !== false) { |
||
50 | $output[] = $this->registryData[$num]->getAuthor(); |
||
51 | } |
||
52 | |||
53 | if (strpos($input, 'album') !== false) { |
||
54 | $output[] = $this->registryData[$num]->getAlbum(); |
||
55 | } |
||
56 | |||
57 | return implode(' ', $output) . "\n"; |
||
58 | } |
||
60 |