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

BorderBuilder::setBorderBottom()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 3
crap 1
1
<?php
2
3
namespace Box\Spout\Writer\Common\Creator\Style;
4
5
use Box\Spout\Writer\Common\Entity\Style\Border;
6
use Box\Spout\Writer\Common\Entity\Style\BorderPart;
7
use Box\Spout\Writer\Common\Entity\Style\Color;
8
9
/**
10
 * Class BorderBuilder
11
 *
12
 * @package \Box\Spout\Writer\Common\Creator\Style
13
 */
14
class BorderBuilder
15
{
16
    /**
17
     * @var Border
18
     */
19
    protected $border;
20
21 9
    public function __construct()
22
    {
23 9
        $this->border = new Border();
24 9
    }
25
26
    /**
27
     * @param string|void $color Border A RGB color code
28
     * @param string|void $width Border width @see BorderPart::allowedWidths
29
     * @param string|void $style Border style @see BorderPart::allowedStyles
30
     * @return BorderBuilder
31
     */
32 4
    public function setBorderTop($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
33
    {
34 4
        $this->border->addPart(new BorderPart(Border::TOP, $color, $width, $style));
35 4
        return $this;
36
    }
37
38
    /**
39
     * @param string|void $color Border A RGB color code
40
     * @param string|void $width Border width @see BorderPart::allowedWidths
41
     * @param string|void $style Border style @see BorderPart::allowedStyles
42
     * @return BorderBuilder
43
     */
44 3
    public function setBorderRight($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
45
    {
46 3
        $this->border->addPart(new BorderPart(Border::RIGHT, $color, $width, $style));
47 3
        return $this;
48
    }
49
50
    /**
51
     * @param string|void $color Border A RGB color code
52
     * @param string|void $width Border width @see BorderPart::allowedWidths
53
     * @param string|void $style Border style @see BorderPart::allowedStyles
54
     * @return BorderBuilder
55
     */
56 8
    public function setBorderBottom($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
57
    {
58 8
        $this->border->addPart(new BorderPart(Border::BOTTOM, $color, $width, $style));
59 8
        return $this;
60
    }
61
62
    /**
63
     * @param string|void $color Border A RGB color code
64
     * @param string|void $width Border width @see BorderPart::allowedWidths
65
     * @param string|void $style Border style @see BorderPart::allowedStyles
66
     * @return BorderBuilder
67
     */
68 3
    public function setBorderLeft($color = Color::BLACK, $width = Border::WIDTH_MEDIUM, $style = Border::STYLE_SOLID)
69
    {
70 3
        $this->border->addPart(new BorderPart(Border::LEFT, $color, $width, $style));
71 3
        return $this;
72
    }
73
74
    /**
75
     * @return Border
76
     */
77 9
    public function build()
78
    {
79 9
        return $this->border;
80
    }
81
}
82