Completed
Push — develop ( 7a734f...e9a151 )
by Stefan
03:10
created

Fill   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 67
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 68.75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 67
ccs 11
cts 16
cp 0.6875
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A style() 0 4 1
A setColor() 0 6 1
A setPattern() 0 5 1
A asXml() 0 7 2
1
<?php
2
3
namespace OneSheet\Style;
4
5
use OneSheet\Xml\StyleXml;
6
7
/**
8
 * Class Fill
9
 *
10
 * @package OneSheet
11
 */
12
class Fill
13
{
14
    /**
15
     * @var string
16
     */
17
    private $color;
18
19
    /**
20
     * @var string
21
     */
22
    private $pattern = 'none';
23
24
    /**
25
     * @var Style
26
     */
27
    private $style;
28
29
    /**
30
     * Font constructor.
31
     *
32
     * @param Style $style
33
     */
34 3
    public function __construct(Style $style)
35
    {
36 3
        $this->style = $style;
37 3
    }
38
39
    /**
40
     * @return Style
41
     */
42 2
    public function style()
43
    {
44 2
        return $this->style;
45
    }
46
47
    /**
48
     * @param string $color
49
     * @return Fill
50
     */
51
    public function setColor($color)
52
    {
53
        $this->color = $color;
54
        $this->pattern = 'solid';
55
        return $this;
56
    }
57
58
    /**
59
     * @param string $pattern
60
     * @return Fill
61
     */
62 2
    public function setPattern($pattern)
63
    {
64 2
        $this->pattern = $pattern;
65 2
        return $this;
66
    }
67
68
    /**
69
     * @return string
70
     */
71 2
    public function asXml()
72
    {
73 2
        if ($this->color) {
74
            return sprintf(StyleXml::COLORED_FILL_XML, $this->color);
75
        }
76 2
        return sprintf(StyleXml::BLANK_FILL_XML, $this->pattern);
77
    }
78
}
79