Test Failed
Push — master ( 15b6af...d076c2 )
by BruceScrutinizer
08:02
created

isInPrivateConfiguredEntries::apply()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 11
rs 10
1
<?php declare(strict_types=1);
2
3
namespace NamespaceProtector\Rule;
4
5
use NamespaceProtector\Entry\Entry;
6
use NamespaceProtector\Config\Config;
7
use NamespaceProtector\Db\BooleanMatchNameSpace;
8
use NamespaceProtector\Parser\Node\MatchedResult;
9
use NamespaceProtector\Db\MatchCollectionInterface;
10
use NamespaceProtector\Parser\Node\MatchedResultInterface;
11
use NamespaceProtector\Parser\Node\Event\EventProcessNodeInterface;
12
13
class isInPrivateConfiguredEntries implements RuleInterface
14
{
15
    private Config $config;
16
17
    public function __construct(Config $config)
18
    {
19
        $this->config = $config;
20
    }
21
22
    public function apply(Entry $entry, EventProcessNodeInterface $event): bool
23
    {
24
        /** @var MatchedResult */
25
        $result = $this->isInPrivateConfiguredEntries($entry, new BooleanMatchNameSpace());
26
27
        if ($result->matched()) {
28
            $event->foundError($result->getInfo());
0 ignored issues
show
Bug introduced by
The method getInfo() does not exist on NamespaceProtector\Parser\Node\EmptyMatchedResult. ( Ignorable by Annotation )

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

28
            $event->foundError($result->/** @scrutinizer ignore-call */ getInfo());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
            return true;
30
        }
31
32
        return false;
33
    }
34
35
    private function isInPrivateConfiguredEntries(Entry $currentNamespaceAccess, MatchCollectionInterface $macher): MatchedResultInterface
36
    {
37
        return $macher->evaluate($this->config->getPrivateEntries(), $currentNamespaceAccess);
38
    }
39
}
40