XmlSchemaValidatorFactory::getValidator()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 9
ccs 5
cts 5
cp 1
crap 2
rs 10
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 2
    public function getValidator(string $id): SchemaValidatorInterface
13
    {
14 2
        $this->assertHasSchema($id);
15
16 2
        if (!$this->registeredSchemas[$id] instanceof XmlSchemaValidator) {
17 2
            $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]) can also be of type array; however, parameter $schemaLocation of Spiechu\SymfonyCommonsBu...alidator::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

17
            $this->registeredSchemas[$id] = new XmlSchemaValidator(/** @scrutinizer ignore-type */ $this->fileLocator->locate($this->registeredSchemas[$id]));
Loading history...
18
        }
19
20 2
        return $this->registeredSchemas[$id];
21
    }
22
}
23