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

StaticNode::push()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

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