Completed
Push — master ( 1ff41e...4d0f8f )
by Stefan
02:53
created

Fill::getId()   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 1
Metric Value
c 1
b 0
f 1
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 implements Component
13
{
14
    /**
15
     * @var int
16
     */
17
    private $id;
18
19
    /**
20
     * @var string
21
     */
22
    private $color;
23
24
    /**
25
     * @var string
26
     */
27
    private $pattern = 'none';
28
29
    /**
30
     * @param int $id
31
     * @return Fill
32
     */
33 4
    public function setId($id)
34
    {
35 4
        $this->id = $id;
36 4
        return $this;
37
    }
38
39
    /**
40
     * @return int
41
     */
42 4
    public function getId()
43
    {
44 4
        return $this->id;
45
    }
46
47
    /**
48
     * @param string $color
49
     * @return Fill
50
     */
51 2
    public function setColor($color)
52
    {
53 2
        $this->color = strtoupper($color);
54 2
        return $this;
55
    }
56
57
    /**
58
     * @param string $pattern
59
     * @return Fill
60
     */
61 5
    public function setPattern($pattern)
62
    {
63 5
        $this->pattern = $pattern;
64 5
        return $this;
65
    }
66
67
    /**
68
     * @return string
69
     */
70 5
    public function asXml()
71
    {
72 5
        if ($this->color) {
73 1
            return sprintf(StyleXml::COLORED_FILL_XML, $this->color);
74
        }
75 5
        return sprintf(StyleXml::PATTERN_FILL_XML, $this->pattern);
76
    }
77
}
78