VarDumpAction   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 39
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A execute() 0 16 3
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\Php\Action;
11
12
use NextFlow\Core\Action\AbstractAction;
13
14
/**
15
 * An action that var_dumps the bound value.
16
 */
17
final class VarDumpAction extends AbstractAction
18
{
19
    /** The constant that defines the output socket. */
20
    const SOCKET_OUTPUT = 'out';
21
22
    /** The socket that holds the data variable. */
23
    const SOCKET_DATA = 'data';
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_DATA);
34
    }
35
36
    /**
37
     * Executes the node's logic.
38
     */
39
    public function execute()
40
    {
41
        $socket = $this->getSocket(self::SOCKET_DATA);
42
        if ($socket->getNodeCount() === 0) {
43
            return;
44
        }
45
46
        $data = $socket->getNode(0)->getValue();
47
        if ($data === null) {
48
            throw new \InvalidArgumentException('There is not data set.');
49
        }
50
51
        var_dump($data);
52
53
        $this->activate(self::SOCKET_OUTPUT);
54
    }
55
}
56