Structure::getIteratorCharacter()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 1
cts 1
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Matks\Vivian\Structure;
4
5
use Matks\Vivian\Border\Border;
6
use Exception;
7
8
/**
9
 * Border element
10
 */
11
class Structure
12
{
13
    const TYPE_LIST  = 'list';
14
    const TYPE_ARRAY = 'array';
15
16
    const FOUR_SPACE_TAB = '    ';
17
18
    /**
19
     * @var string
20
     */
21
    private $type;
22
23
    /**
24
     * @var string
25
     */
26
    private $tab;
27
28
    /**
29
     * @var string
30
     */
31
    private $iteratorCharacter;
32
33
    /**
34
     * @var string
35
     */
36
    private $keyToValueCharacter;
37
38
    /**
39
     * @var Border
40
     */
41
    private $border;
42
43
    /**
44
     * @param string $type
45
     * @param string $iteratorCharacter
46
     * @param string $tab
47
     * @param string $keyToValueCharacter
48
     * @param Border $border
49
     */
50
    public function __construct(
51
        $type,
52
        $iteratorCharacter = '#',
53
        $tab = null,
54
        $keyToValueCharacter = '|',
55
        Border $border = null
56
    )
57
    {
58 1
        if (!in_array($type, $this->getAllowedTypes())) {
59 1
            throw new Exception("Unknown structure type $type");
60
        }
61
62 1
        $this->type                = $type;
63 1
        $this->iteratorCharacter   = $iteratorCharacter;
64 1
        $this->tab                 = $tab;
65 1
        $this->keyToValueCharacter = $keyToValueCharacter;
66 1
        $this->border              = $border;
67 1
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getType()
73
    {
74 1
        return $this->type;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getKeyToValueCharacter()
81
    {
82 1
        return $this->keyToValueCharacter;
83
    }
84
85
    /**
86
     * @return string
87
     */
88
    public function getIteratorCharacter()
89
    {
90 1
        return $this->iteratorCharacter;
91
    }
92
93
    /**
94
     * @return string
95
     */
96
    public function getTab()
97
    {
98 1
        return $this->tab;
99
    }
100
101
    /**
102
     * @return Border
103
     */
104
    public function getBorder()
105
    {
106 1
        return $this->border;
107
    }
108
109
    /**
110
     * @return string[]
111
     */
112
    private function getAllowedTypes()
113
    {
114
        $types = array(
115 1
            static::TYPE_LIST,
116 1
            static::TYPE_ARRAY,
117 1
        );
118
119 1
        return $types;
120
    }
121
}
122