| Conditions | 3 |
| Paths | 3 |
| Total Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 39 | 491 | public function inflect(string $word) : string |
|
| 40 | { |
||
| 41 | 491 | $lowerWord = strtolower($word); |
|
| 42 | |||
| 43 | 491 | if (isset($this->substitutions[$lowerWord])) { |
|
| 44 | 150 | $firstLetterUppercase = $lowerWord[0] !== $word[0]; |
|
| 45 | |||
| 46 | 150 | $toWord = $this->substitutions[$lowerWord]->getTo()->getWord(); |
|
| 47 | |||
| 48 | 150 | if ($firstLetterUppercase) { |
|
| 49 | 2 | return strtoupper($toWord[0]) . substr($toWord, 1); |
|
| 50 | } |
||
| 51 | |||
| 52 | 148 | return $toWord; |
|
| 53 | } |
||
| 54 | |||
| 55 | 341 | return $word; |
|
| 56 | } |
||
| 58 |