XmlSchemaValidatorFactory   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
c 0
b 0
f 0
dl 0
loc 14
ccs 5
cts 5
cp 1
rs 10
wmc 2

1 Method

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