If_::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 7
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
rs 9.2
cc 4
eloc 6
nc 8
nop 3
1
<?php
2
3
namespace PhpParser\Node\Stmt;
4
5
use PhpParser\Node;
6
7
class If_ extends Node\Stmt
8
{
9
    /** @var Node\Expr Condition expression */
10
    public $cond;
11
    /** @var Node[] Statements */
12
    public $stmts;
13
    /** @var ElseIf_[] Elseif clauses */
14
    public $elseifs;
15
    /** @var null|Else_ Else clause */
16
    public $else;
17
18
    /**
19
     * Constructs an if node.
20
     *
21
     * @param Node\Expr $cond       Condition
22
     * @param array     $subNodes   Array of the following optional subnodes:
23
     *                              'stmts'   => array(): Statements
24
     *                              'elseifs' => array(): Elseif clauses
25
     *                              'else'    => null   : Else clause
26
     * @param array     $attributes Additional attributes
27
     */
28
    public function __construct(Node\Expr $cond, array $subNodes = array(), array $attributes = array()) {
29
        parent::__construct($attributes);
30
        $this->cond = $cond;
31
        $this->stmts = isset($subNodes['stmts']) ? $subNodes['stmts'] : array();
32
        $this->elseifs = isset($subNodes['elseifs']) ? $subNodes['elseifs'] : array();
33
        $this->else = isset($subNodes['else']) ? $subNodes['else'] : null;
34
    }
35
36
    public function getSubNodeNames() {
37
        return array('cond', 'stmts', 'elseifs', 'else');
38
    }
39
}
40