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

SchemaLocator   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 8
cts 8
cp 1
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A schemaFileExists() 0 8 2
A __construct() 0 3 1
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