Completed
Push — develop ( f460ca...da25db )
by Stefan
03:10
created

Fill::style()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
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
     * @param string $color
26
     * @return Fill
27
     */
28
    public function setColor($color)
29
    {
30
        $this->color = $color;
31
        $this->pattern = 'solid';
32
        return $this;
33
    }
34
35
    /**
36
     * @param string $pattern
37
     * @return Fill
38
     */
39 2
    public function setPattern($pattern)
40
    {
41 2
        $this->pattern = $pattern;
42 2
        return $this;
43
    }
44
45
    /**
46
     * @return string
47
     */
48 2
    public function asXml()
49
    {
50 2
        if ($this->color) {
51
            return sprintf(StyleXml::COLORED_FILL_XML, $this->color);
52
        }
53 2
        return sprintf(StyleXml::BLANK_FILL_XML, $this->pattern);
54
    }
55
}
56