IsInPrivateConfiguredEntries::apply()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace NamespaceProtector\Rule;
6
7
use NamespaceProtector\Entry\Entry;
8
use NamespaceProtector\Config\Config;
9
use NamespaceProtector\Db\BooleanMatchNameSpace;
10
use NamespaceProtector\Parser\Node\MatchedResult;
11
use NamespaceProtector\Db\MatchCollectionInterface;
12
use NamespaceProtector\Parser\Node\MatchedResultInterface;
13
use NamespaceProtector\Parser\Node\Event\EventProcessNodeInterface;
14
15
class IsInPrivateConfiguredEntries implements RuleInterface
16
{
17
    public function __construct(private Config $config)
18
    {
19
    }
20
21
    public function apply(Entry $entry, EventProcessNodeInterface $event): bool
22
    {
23
        /** @var MatchedResult */
24
        $result = $this->isInPrivateConfiguredEntries($entry, new BooleanMatchNameSpace());
25
26
        if ($result->matched()) {
27
            $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

27
            $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...
28
            return true;
29
        }
30
31
        return false;
32
    }
33
34
    private function isInPrivateConfiguredEntries(Entry $currentNamespaceAccess, MatchCollectionInterface $macher): MatchedResultInterface
35
    {
36
        return $macher->evaluate($this->config->getPrivateEntries(), $currentNamespaceAccess);
37
    }
38
}
39