ElementAbstract   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 90
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 1 Features 0
Metric Value
wmc 9
c 4
b 1
f 0
lcom 1
cbo 0
dl 0
loc 90
ccs 24
cts 24
cp 1
rs 10

9 Methods

Rating   Name   Duplication   Size   Complexity  
init() 0 1 ?
toString() 0 1 ?
A __construct() 0 5 1
A getParent() 0 4 1
A setParent() 0 6 1
A setOptions() 0 11 3
A getTabulation() 0 4 1
A getTabulationFormatted() 0 4 1
A setTabulation() 0 6 1
1
<?php
2
3
/*
4
 * This file is part of the ClassGeneration package.
5
 *
6
 * (c) Antonio Spinelli <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ClassGeneration\Element;
13
14
/**
15
 * Abstract ClassGeneration
16
 * @author Antonio Spinelli <[email protected]>
17
 */
18
abstract class ElementAbstract implements ElementInterface, Tabbable
19
{
20
21
    /**
22
     * Tabulation Identity.
23
     * @var int
24
     */
25
    protected $tabulation = 4;
26
27
    /**
28
     * Parent Class.
29
     * @var ElementInterface
30
     */
31
    protected $parent = null;
32
33
    /**
34
     * @{inheritdoc}
35
     */
36
    abstract public function init();
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    abstract public function toString();
42
43 142
    public function __construct($options = array())
44
    {
45 142
        $this->init();
46 142
        $this->setOptions($options);
47 142
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52 2
    public function getParent()
53
    {
54 2
        return $this->parent;
55
    }
56
57
    /**
58
     * {@inheritdoc}
59
     */
60 36
    public function setParent(ElementInterface $parent)
61
    {
62 36
        $this->parent = $parent;
63
64 36
        return $this;
65
    }
66
67
    /**
68
     * {@inheritdoc}
69
     */
70 142
    public function setOptions(array $options)
71
    {
72 142
        foreach ($options as $prop => $option) {
73 76
            $method = 'set' . ucfirst($prop);
74 76
            if (method_exists($this, $method)) {
75 76
                $this->$method($option);
76 76
            }
77 142
        }
78
79 142
        return $this;
80
    }
81
82
    /**
83
     * {@inheritdoc}
84
     */
85 29
    public function getTabulation()
86
    {
87 29
        return $this->tabulation;
88
    }
89
90
    /**
91
     * {@inheritdoc}
92
     */
93 26
    public function getTabulationFormatted()
94
    {
95 26
        return str_repeat(' ', $this->getTabulation());
96
    }
97
98
    /**
99
     * @inheritdoc
100
     */
101 46
    public function setTabulation($tabulation)
102
    {
103 46
        $this->tabulation = (int)$tabulation;
104
105 46
        return $this;
106
    }
107
}
108