| Conditions | 7 |
| Paths | 5 |
| Total Lines | 16 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 7 |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 42 | 6 | public static function fillFromPaths(RoutedPath $path, string $defaultLang, bool $moreLangs): string |
|
| 43 | { |
||
| 44 | 6 | if ($path->getLang()) { |
|
| 45 | 4 | return $path->getLang(); |
|
| 46 | } |
||
| 47 | 3 | if ($moreLangs && !empty($path->getPath())) { |
|
| 48 | 2 | $trace = $path->getPath(); |
|
| 49 | 2 | $firstDir = reset($trace); |
|
| 50 | 2 | if (false !== $firstDir) { |
|
| 51 | 2 | $length = strlen($firstDir); |
|
| 52 | 2 | if ((1 < $length) && (4 > $length)) { // two-letter "en", three letter "eng" |
|
| 53 | 2 | return $firstDir; |
|
| 54 | } |
||
| 55 | } |
||
| 56 | } |
||
| 57 | 3 | return $defaultLang; |
|
| 58 | } |
||
| 60 |