Completed
Pull Request — master (#273)
by Hura
13:16
created

Border::getParts()   A

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 Box\Spout\Writer\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
    /**
26
     * @var array A list of BorderPart objects for this border.
27
     */
28
    protected $parts = [];
29
30
    /**
31
     * @param array|void $borderParts
32
     */
33 27
    public function __construct(array $borderParts = [])
34
    {
35 27
        $this->setParts($borderParts);
36 27
    }
37
38
    /**
39
     * @param $name The name of the border part
40
     * @return null|BorderPart
41 18
     */
42
    public function getPart($name)
43 18
    {
44
        return $this->hasPart($name) ? $this->parts[$name] : null;
45
    }
46
47
    /**
48
     * @param $name The name of the border part
49
     * @return bool
50 27
     */
51
    public function hasPart($name)
52 27
    {
53 27
        return isset($this->parts[$name]);
54 6
    }
55 27
56 27
    /**
57
     * @return array
58
     */
59
    public function getParts()
60
    {
61
        return $this->parts;
62 27
    }
63
64 27
    /**
65 27
     * Set BorderParts
66
     * @param array $parts
67
     */
68
    public function setParts($parts)
69
    {
70
        unset($this->parts);
71
        foreach ($parts as $part) {
72
            $this->addPart($part);
73
        }
74
    }
75
76
    /**
77
     * @param BorderPart $borderPart
78
     * @return self
79
     */
80
    public function addPart(BorderPart $borderPart)
81
    {
82
        $this->parts[$borderPart->getName()] = $borderPart;
83
        return $this;
84
    }
85
}
86