Completed
Push — master ( 993520...f97157 )
by Dawid
06:13
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\SchemaValidator;
6
7
class XmlSchemaValidatorFactory extends AbstractSchemaValidatorFactory implements SchemaValidatorFactoryInterface
8
{
9
    /**
10
     * {@inheritdoc}
11
     */
12 1
    public function getValidator(string $id): SchemaValidatorInterface
13
    {
14 1
        $this->assertHasSchema($id);
15
16 1
        if (!$this->registeredSchemas[$id] instanceof XmlSchemaValidator) {
17 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...
18
        }
19
20 1
        return $this->registeredSchemas[$id];
21
    }
22
}
23