Completed
Push — master ( 993520...f97157 )
by Dawid
06:13
created

XmlSchemaValidatorFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
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 16
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\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