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

SchemaLocator::schemaFileExists()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
ccs 5
cts 5
cp 1
crap 2
rs 9.4285
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