Test Failed
Push — master ( 36eeda...83b81c )
by BruceScrutinizer
08:00
created

IsInPrivateConfiguredEntries::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
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