Completed
Push — master ( 4207f0...333332 )
by Kamil
23:19 queued 01:42
created

ApplicationResourceLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 3
c 2
b 1
f 0
lcom 1
cbo 3
dl 0
loc 28
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A locateResource() 0 9 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\ThemeBundle\Locator;
13
14
use Sylius\Bundle\ThemeBundle\Model\ThemeInterface;
15
use Symfony\Component\Filesystem\Filesystem;
16
17
/**
18
 * @author Kamil Kokot <[email protected]>
19
 */
20
final class ApplicationResourceLocator implements ResourceLocatorInterface
21
{
22
    /**
23
     * @var Filesystem
24
     */
25
    private $filesystem;
26
27
    /**
28
     * @param Filesystem $filesystem
29
     */
30
    public function __construct(Filesystem $filesystem)
31
    {
32
        $this->filesystem = $filesystem;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function locateResource($resourceName, ThemeInterface $theme)
39
    {
40
        $path = sprintf('%s/%s', $theme->getPath(), $resourceName);
41
        if (!$this->filesystem->exists($path)) {
42
            throw new ResourceNotFoundException($resourceName, $theme);
43
        }
44
45
        return $path;
46
    }
47
}
48