Completed
Push — spi_getname_change ( 5d4921...c435e1 )
by André
23:05
created

ServiceAwareMatcherFactory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 2
Bugs 1 Features 1
Metric Value
wmc 2
c 2
b 1
f 1
lcom 0
cbo 3
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A getMatcher() 0 8 2
1
<?php
2
/**
3
 * @license For full copyright and license information view LICENSE file distributed with this source code.
4
 */
5
namespace eZ\Bundle\EzPublishCoreBundle\Matcher;
6
7
use eZ\Publish\Core\MVC\Symfony\Matcher\ClassNameMatcherFactory;
8
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
9
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
10
11
/**
12
 * A view matcher factory that also accepts services as matchers.
13
 *
14
 * If a service id is passed as the MatcherIdentifier, this service will be used for the matching.
15
 * Otherwise, it will fallback to the class name based matcher factory.
16
 */
17
class ServiceAwareMatcherFactory extends ClassNameMatcherFactory implements ContainerAwareInterface
18
{
19
    use ContainerAwareTrait;
20
21
    /**
22
     * @param string $matcherIdentifier
23
     *
24
     * @return \eZ\Publish\Core\MVC\Symfony\Matcher\ContentBased\MatcherInterface
25
     */
26
    protected function getMatcher($matcherIdentifier)
27
    {
28
        if ($this->container->has($matcherIdentifier)) {
29
            return $this->container->get($matcherIdentifier);
30
        }
31
32
        return parent::getMatcher($matcherIdentifier);
0 ignored issues
show
Bug Compatibility introduced by
The expression parent::getMatcher($matcherIdentifier); of type eZ\Publish\Core\MVC\Symf...er\ViewMatcherInterface adds the type eZ\Publish\Core\MVC\Symf...er\ViewMatcherInterface to the return on line 32 which is incompatible with the return type documented by eZ\Bundle\EzPublishCoreB...cherFactory::getMatcher of type eZ\Publish\Core\MVC\Symf...tBased\MatcherInterface.
Loading history...
33
    }
34
}
35