| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 28 | private function translateAbbreviation(string $abbreviation): string |
||
| 29 | { |
||
| 30 | $bookAbbreviations = require __DIR__ . '/../data/books.php'; |
||
| 31 | $bookNames = require __DIR__ . '/../data/bookNames.php'; |
||
| 32 | |||
| 33 | $abbreviation = strtolower($abbreviation); |
||
| 34 | $abbreviation = preg_replace('/[^a-z0-9 ]/', '', $abbreviation); |
||
| 35 | $abbreviation = trim($abbreviation); |
||
| 36 | |||
| 37 | if (!array_key_exists($abbreviation, $bookAbbreviations)) { |
||
| 38 | throw InvalidBookException::invalidBook($abbreviation); |
||
| 39 | } |
||
| 40 | |||
| 41 | $bookNumber = $bookAbbreviations[$abbreviation]; |
||
| 42 | |||
| 43 | return $bookNames[$bookNumber]; |
||
| 44 | } |
||
| 46 |