| Conditions | 5 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 11 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 5 |
| Changes | 0 | ||
| 1 | <?php |
||
| 41 | 2 | public function __invoke(string $name) : string |
|
| 42 | { |
||
| 43 | 2 | $templatePath = $this->templateFinder->__invoke($name); |
|
| 44 | 2 | $detect = new \Mobile_Detect(null, $this->userAgent); |
|
| 45 | 2 | $isMobile = $detect->isMobile() && ! $detect->isTablet(); |
|
| 46 | 2 | if ($isMobile) { |
|
| 47 | 1 | $mobilePath = str_replace('.html.twig', '.mobile.twig', $templatePath); |
|
| 48 | 1 | foreach ($this->paths as $path) { |
|
| 49 | 1 | $mobileFile = sprintf('%s/%s', $path, $mobilePath); |
|
| 50 | 1 | if (file_exists($mobileFile)) { |
|
| 51 | 1 | return $mobilePath; |
|
| 52 | } |
||
| 53 | } |
||
| 54 | } |
||
| 55 | |||
| 56 | 1 | return $templatePath; |
|
| 57 | } |
||
| 58 | } |
||
| 59 |