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

XmlSchemaValidatorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 3
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getValidator() 0 10 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