Passed
Pull Request — 2.x (#539)
by Aleksei
15:43
created

StaticNode   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A push() 0 7 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cycle\ORM\Parser;
6
7
/**
8
 * This node is used when entity data is already loaded.
9
 *
10
 * @internal
11
 */
12
final class StaticNode extends OutputNode
13
{
14
    /**
15
     * @param non-empty-string[] $columns
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...
16
     * @param non-empty-string[] $primaryKeys
17
     */
18
    public function __construct(array $columns, array $primaryKeys)
19
    {
20
        parent::__construct($columns, null);
21
        $this->setDuplicateCriteria($primaryKeys);
22
    }
23
24
    public function push(array &$data): void
25
    {
26
        parent::push($data);
27
        foreach ($this->indexedData->getIndexes() as $index) {
28
            try {
29
                $this->indexedData->addItem($index, $data);
30
            } catch (\Throwable) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
31
            }
32
        }
33
34
        // // Let's force placeholders for every sub loaded
35
        // foreach ($this->nodes as $name => $node) {
36
        //     if ($node instanceof ParentMergeNode) {
37
        //         continue;
38
        //     }
39
        //     $data[$name] = $node instanceof ArrayNode ? [] : null;
40
        // }
41
    }
42
}
43