Passed
Push — master ( cce2e1...993520 )
by Dawid
02:22
created

XmlSchemaValidatorFactory::getValidator()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiechu\SymfonyCommonsBundle\Service;
6
7
use Symfony\Component\Config\Exception\FileLocatorFileNotFoundException;
8
9
class XmlSchemaValidatorFactory extends AbstractSchemaValidatorFactory
10
{
11
    /**
12
     * @param string $id
13
     *
14
     * @throws FileLocatorFileNotFoundException
15
     * @throws \InvalidArgumentException
16
     * @throws \RuntimeException
17
     *
18
     * @return XmlSchemaValidator
19
     */
20 1
    public function getValidator(string $id): XmlSchemaValidator
21
    {
22 1
        $this->assertHasSchema($id);
23
24 1
        if (!$this->registeredSchemas[$id] instanceof XmlSchemaValidator) {
25 1
            $this->registeredSchemas[$id] = new XmlSchemaValidator($this->fileLocator->locate($this->registeredSchemas[$id]));
0 ignored issues
show
Bug introduced by
It seems like $this->fileLocator->loca...registeredSchemas[$id]) targeting Symfony\Component\Config...atorInterface::locate() can also be of type array; however, Spiechu\SymfonyCommonsBu...alidator::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
26
        }
27
28 1
        return $this->registeredSchemas[$id];
29
    }
30
}
31