Completed
Push — master ( 328cff...6ebda6 )
by Luc
10s
created

ClassNameEventSpecification::matches()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
dl 10
loc 10
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 3
nop 1
1
<?php
2
3
namespace CultuurNet\UDB3\EventListener;
4
5
use ValueObjects\StringLiteral\StringLiteral;
6
7 View Code Duplication
class ClassNameEventSpecification implements EventSpecification
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
8
{
9
    private $classNames;
10
11
    /**
12
     * ClassNameCommandFilter constructor.
13
     * @param StringLiteral[] $classNames
14
     */
15
    public function __construct(StringLiteral ...$classNames)
16
    {
17
        $this->classNames = $classNames;
18
    }
19
20
    /**
21
     * @inheritdoc
22
     */
23
    public function matches($event)
24
    {
25
        foreach ($this->classNames as $className) {
26
            if (get_class($event) === $className->toNative()) {
0 ignored issues
show
Bug introduced by
The method toNative cannot be called on $className (of type array<integer,object<Val...Literal\StringLiteral>>).

Methods can only be called on objects. This check looks for methods being called on variables that have been inferred to never be objects.

Loading history...
27
                return true;
28
            }
29
        }
30
31
        return false;
32
    }
33
}
34