Passed
Push — main ( 1402e3...cedac2 )
by Thierry
18:03
created

Scope::__construct()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 4
eloc 7
c 1
b 0
f 0
nc 4
nop 3
dl 0
loc 10
rs 10
1
<?php
2
3
namespace Lagdo\UiBuilder\Html\Support;
4
5
use AvpLab\Element\Text;
6
7
use function is_string;
8
use function is_array;
9
10
class Scope
11
{
12
    /**
13
     * @var string
14
     */
15
    public $name;
16
17
    /**
18
     * @var Scope|null
19
     */
20
    public $parent;
21
22
    /**
23
     * @var array
24
     */
25
    public $attributes = [];
26
27
    /**
28
     * @var array
29
     */
30
    public $escapes = [];
31
32
    /**
33
     * @var array
34
     */
35
    public $elements = [];
36
37
    /**
38
     * The constructor
39
     *
40
     * @param string $name
41
     * @param array $arguments
42
     * @param Scope|null $parent
43
     */
44
    public function __construct(string $name, array $arguments = [], ?Scope $parent = null)
45
    {
46
        $this->name = $name;
47
        $this->parent = $parent;
48
        // Resolve arguments
49
        foreach ($arguments as $argument) {
50
            if (is_string($argument)) {
51
                $this->elements[] = new Text($argument, false);
52
            } elseif (is_array($argument)) {
53
                $this->attributes = $argument;
54
            }
55
        }
56
    }
57
}
58