Failed Conditions
Push — perf-tests ( 2fc93e...db6806 )
by Adrien
13:45
created

BorderBuilder   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 2
dl 0
loc 68
rs 10

6 Methods

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