Completed
Push — master ( 82aeee...e45d47 )
by Dawid
05:00
created

SchemaLocator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Service;
6
7
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
8
use Symfony\Component\Config\FileLocatorInterface;
9
10
class SchemaLocator
11
{
12
    /**
13
     * @var FileLocatorInterface
14
     */
15
    protected $fileLocator;
16
17
    /**
18
     * @param FileLocatorInterface $fileLocator
19
     */
20 23
    public function __construct(FileLocatorInterface $fileLocator)
21
    {
22 23
        $this->fileLocator = $fileLocator;
23 23
    }
24
25
    /**
26
     * @param string $schemaLocation
27
     *
28
     * @return bool
29
     */
30 19
    public function schemaFileExists(string $schemaLocation): bool
31
    {
32
        try {
33 19
            $this->fileLocator->locate($schemaLocation);
34
35 19
            return true;
36 1
        } catch (FileLocatorFileNotFoundException $e) {
37 1
            return false;
38
        }
39
    }
40
}
41