Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
TwigLoader
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
1 / 1
 findTemplate
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3declare(strict_types=1);
4
5namespace Engelsystem\Renderer;
6
7use Twig\Error\LoaderError as ErrorLoader;
8use Twig\Loader\FilesystemLoader as FilesystemLoader;
9
10class TwigLoader extends FilesystemLoader
11{
12    /**
13     * @throws ErrorLoader
14     */
15    public function findTemplate(string $name, bool $throw = true): ?string
16    {
17        $extension = '.twig';
18        $extensionLength = mb_strlen($extension);
19        if (mb_substr($name, -$extensionLength, $extensionLength) !== $extension) {
20            $name .= $extension;
21        }
22
23        return parent::findTemplate($name, $throw);
24    }
25}