Border   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 78
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPart() 0 4 2
A hasPart() 0 4 1
A getParts() 0 4 1
A setParts() 0 7 2
A addPart() 0 6 1
1
<?php
2
3
namespace Box\Spout\Common\Entity\Style;
4
5
/**
6
 * Class Border
7
 */
8
class Border
9
{
10
    const LEFT = 'left';
11
    const RIGHT = 'right';
12
    const TOP = 'top';
13
    const BOTTOM = 'bottom';
14
15
    const STYLE_NONE = 'none';
16
    const STYLE_SOLID = 'solid';
17
    const STYLE_DASHED = 'dashed';
18
    const STYLE_DOTTED = 'dotted';
19
    const STYLE_DOUBLE = 'double';
20
21
    const WIDTH_THIN = 'thin';
22
    const WIDTH_MEDIUM = 'medium';
23
    const WIDTH_THICK = 'thick';
24
25
    /** @var array A list of BorderPart objects for this border. */
26
    private $parts = [];
27
28
    /**
29
     * @param array $borderParts
30
     */
31 12
    public function __construct(array $borderParts = [])
32
    {
33 12
        $this->setParts($borderParts);
34 12
    }
35
36
    /**
37
     * @param string $name The name of the border part
38
     * @return BorderPart|null
39
     */
40 4
    public function getPart($name)
41
    {
42 4
        return $this->hasPart($name) ? $this->parts[$name] : null;
43
    }
44
45
    /**
46
     * @param string $name The name of the border part
47
     * @return bool
48
     */
49 4
    public function hasPart($name)
50
    {
51 4
        return isset($this->parts[$name]);
52
    }
53
54
    /**
55
     * @return array
56
     */
57 5
    public function getParts()
58
    {
59 5
        return $this->parts;
60
    }
61
62
    /**
63
     * Set BorderParts
64
     * @param array $parts
65
     * @return void
66
     */
67 12
    public function setParts($parts)
68
    {
69 12
        unset($this->parts);
70 12
        foreach ($parts as $part) {
71 1
            $this->addPart($part);
72
        }
73 12
    }
74
75
    /**
76
     * @param BorderPart $borderPart
77
     * @return Border
78
     */
79 12
    public function addPart(BorderPart $borderPart)
80
    {
81 12
        $this->parts[$borderPart->getName()] = $borderPart;
82
83 12
        return $this;
84
    }
85
}
86