Border::getCrossCharacter()   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\Border;
4
5
use Exception;
6
7
/**
8
 * Border element
9
 */
10
class Border
11
{
12
    const TYPE_UNDERLINE = 'underline';
13
    const TYPE_FRAME     = 'frame';
14
15
    /**
16
     * @var string
17
     */
18
    private $type;
19
20
    /**
21
     * @var string
22
     */
23
    private $lineCharacter;
24
25
    /**
26
     * @var string
27
     */
28
    private $columnCharacter;
29
30
    /**
31
     * @var string
32
     */
33
    private $crossCharacter;
34
35
    /**
36
     * @param string $type
37
     * @param string $lineCharacter
38
     * @param string $columnCharacter
39
     * @param string $crossCharacter
40
     */
41
    public function __construct($type, $lineCharacter = '-', $columnCharacter = '|', $crossCharacter = '+')
42
    {
43 1
        if (!in_array($type, $this->getAllowedTypes())) {
44 1
            throw new Exception("Unknown border type $type");
45
        }
46
47 1
        $this->type            = $type;
48 1
        $this->lineCharacter   = $lineCharacter;
49 1
        $this->columnCharacter = $columnCharacter;
50 1
        $this->crossCharacter  = $crossCharacter;
51 1
    }
52
53
    /**
54
     * @return string
55
     */
56
    public function getType()
57
    {
58 1
        return $this->type;
59
    }
60
61
    /**
62
     * @return string
63
     */
64
    public function getColumnCharacter()
65
    {
66 1
        return $this->columnCharacter;
67
    }
68
69
    /**
70
     * @return string
71
     */
72
    public function getCrossCharacter()
73
    {
74 1
        return $this->crossCharacter;
75
    }
76
77
    /**
78
     * @return string
79
     */
80
    public function getLineCharacter()
81
    {
82 1
        return $this->lineCharacter;
83
    }
84
85
    /**
86
     * @return string[]
87
     */
88
    private function getAllowedTypes()
89
    {
90
        $types = array(
91 1
            static::TYPE_UNDERLINE,
92 1
            static::TYPE_FRAME,
93 1
        );
94
95 1
        return $types;
96
    }
97
}
98