ClearAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 3
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A execute() 0 11 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\Action\AbstractAction;
13
14
/**
15
 * Clears an array.
16
 */
17
final class ClearAction extends AbstractAction
18
{
19
    /** The output action socket. */
20
    const SOCKET_OUTPUT = 'out';
21
22
    /** The array variable socket. */
23
    const SOCKET_ARRAY = 'array';
24
25
    /**
26
     * Initializes a new instance of this class.
27
     */
28
    public function __construct()
29
    {
30
        parent::__construct();
31
32
        $this->createSocket(self::SOCKET_OUTPUT);
33
        $this->createSocket(self::SOCKET_ARRAY);
34
    }
35
36
    /**
37
     * Executes the node's logic.
38
     */
39
    public function execute()
40
    {
41
        $array = $this->getSocket(self::SOCKET_ARRAY)->getNode(0);
42
        if ($array === null) {
43
            throw new \InvalidArgumentException('No array variable provided.');
44
        }
45
46
        $array->setValue(array());
47
48
        $this->activate(self::SOCKET_OUTPUT);
49
    }
50
}
51