Border::getPart()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
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