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

ApplicationResourceLocator::locateResource()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
dl 0
loc 9
rs 9.6666
c 2
b 1
f 0
cc 2
eloc 5
nc 2
nop 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