Completed
Push — master ( aa8cda...5a4e71 )
by Martin
02:52
created

FrontMatterLoader::isFresh()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php
2
3
/*
4
 * This is part of the webuni/front-matter package.
5
 *
6
 * (c) Martin Hasoň <[email protected]>
7
 * (c) Webuni s.r.o. <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
namespace Webuni\FrontMatter\Twig;
14
15
use Twig\Loader\LoaderInterface;
16
use Twig\Source;
17
use Webuni\FrontMatter\FrontMatterInterface;
18
19
class FrontMatterLoader implements LoaderInterface
20
{
21
    private $loader;
22
    private $parser;
23
24
    public function __construct(FrontMatterInterface $parser, LoaderInterface $loader)
25
    {
26
        $this->loader = $loader;
27
        $this->parser = $parser;
28
    }
29
30
    public function getCacheKey($name): string
31
    {
32
        return $this->loader->getCacheKey($name);
33
    }
34
35
    public function isFresh($name, $time): bool
36
    {
37
        return $this->loader->isFresh($name, $time);
38
    }
39
40
    public function exists($name)
41
    {
42
        return $this->loader->exists($name);
43
    }
44
45
    public function getSourceContext($name): Source
46
    {
47
        $source = $this->loader->getSourceContext($name);
48
49
        return new Source($this->parser->parse($source->getCode(), ['filename' => $name]), $source->getName(), $source->getPath());
0 ignored issues
show
Unused Code introduced by
The call to FrontMatterInterface::parse() has too many arguments starting with array('filename' => $name).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
50
    }
51
}
52