Border   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 7
c 5
b 1
f 1
lcom 0
cbo 0
dl 0
loc 88
ccs 15
cts 15
cp 1
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getType() 0 4 1
A getColumnCharacter() 0 4 1
A getCrossCharacter() 0 4 1
A getLineCharacter() 0 4 1
A getAllowedTypes() 0 9 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