Completed
Pull Request — develop_3.0 (#432)
by Adrien
02:31
created

Border::hasPart()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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