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

Fill::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
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