Passed
Pull Request — 2.x (#537)
by Aleksei
17:46
created

ProxyNode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 32
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A addNode() 0 8 2
A push() 0 2 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Parser;
6
7
/**
8
 * Proxy node that holds pitched nodes.
9
 *
10
 * Proxies pitched nodes to parent node.
11
 *
12
 * @internal
13
 */
14
final class ProxyNode extends AbstractNode
15
{
16
    /**
17
     * @var array<non-empty-string, AbstractNode> Indexed pitched nodes
0 ignored issues
show
Documentation Bug introduced by
The doc comment array<non-empty-string, AbstractNode> at position 2 could not be parsed: Unknown type name 'non-empty-string' at position 2 in array<non-empty-string, AbstractNode>.
Loading history...
18
     */
19
    private array $includeNodes = [];
20
21
    /**
22
     * @param list<non-empty-string> $innerKeys
0 ignored issues
show
Bug introduced by
The type Cycle\ORM\Parser\list was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
     */
24
    public function __construct(array $innerKeys)
25
    {
26
        parent::__construct([], $innerKeys);
27
    }
28
29
    /**
30
     * Add pitched node to proxy.
31
     *
32
     * @param non-empty-string $target
0 ignored issues
show
Documentation Bug introduced by
The doc comment non-empty-string at position 0 could not be parsed: Unknown type name 'non-empty-string' at position 0 in non-empty-string.
Loading history...
33
     */
34
    public function addNode(string $target, AbstractNode $node): AbstractNode
35
    {
36
        if (!\array_key_exists($target, $this->includeNodes)) {
37
            $this->includeNodes[$target] = $node;
38
            $this->parent->linkNode($this->container, $node);
0 ignored issues
show
Bug introduced by
The method linkNode() does not exist on null. ( Ignorable by Annotation )

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

38
            $this->parent->/** @scrutinizer ignore-call */ 
39
                           linkNode($this->container, $node);

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...
39
        }
40
41
        return $this->includeNodes[$target];
42
    }
43
44
    protected function push(array &$data): void
45
    {
46
        // BelongsToMorphedNode doesn't store data itself
47
        // Data is pushed to child nodes by role
48
    }
49
}
50