ManifestVersionStrategy::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
ccs 3
cts 3
cp 1
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Rj\FrontendBundle\VersionStrategy;
4
5
use Rj\FrontendBundle\Manifest\Loader\ManifestLoaderInterface;
6
use Rj\FrontendBundle\Manifest\Manifest;
7
use Symfony\Component\Asset\VersionStrategy\VersionStrategyInterface;
8
9
class ManifestVersionStrategy implements VersionStrategyInterface
10
{
11
    /**
12
     * @var ManifestLoaderInterface
13
     */
14
    private $loader;
15
16
    /**
17
     * @var null|Manifest
18
     */
19
    private $manifest = null;
20
21
    /**
22
     * @param ManifestLoaderInterface $loader
23
     */
24 4
    public function __construct(ManifestLoaderInterface $loader)
25
    {
26 4
        $this->loader = $loader;
27 4
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32
    public function getVersion($path)
33
    {
34
        return '';
35
    }
36
37
    /**
38
     * {@inheritdoc}
39
     */
40 4
    public function applyVersion($path)
41
    {
42 4
        if ($this->manifest === null) {
43 4
            $this->manifest = $this->loader->load();
44
        }
45
46 4
        if (!$this->manifest->has($path)) {
47 1
            return $path;
48
        }
49
50 4
        return $this->manifest->get($path);
51
    }
52
}
53