PushFrontAction::executePush()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * NextFlow (http://github.com/nextflow)
4
 *
5
 * @link http://github.com/nextflow/nextflow-php for the canonical source repository
6
 * @copyright Copyright (c) 2014-2016 NextFlow (http://github.com/nextflow)
7
 * @license https://raw.github.com/nextflow/nextflow-php/master/LICENSE MIT
8
 */
9
10
namespace NextFlow\Arrays\Action;
11
12
use NextFlow\Core\Node\NodeInterface;
13
14
/**
15
 * Pushes an element at the front of an array.
16
 */
17
final class PushFrontAction extends AbstractPushAction
18
{
19
    /**
20
     * Executes the push logic.
21
     *
22
     * @param NodeInterface $node The node to push data to.
23
     * @param mixed $value The value to push.
24
     */
25
    protected function executePush(NodeInterface $node, $value)
26
    {
27
        $arrayValue = $node->getValue();
28
29
        array_unshift($arrayValue, $value);
30
31
        $node->setValue($arrayValue);
32
    }
33
}
34