Completed
Pull Request — master (#649)
by Adrien
03:03 queued 33s
created

BorderBuilder::setBorderTop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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