Completed
Pull Request — master (#7)
by Stefan
03:14
created

Font::getSize()   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 Font
9
 *
10
 * @package OneSheet
11
 */
12
class Font implements Component
13
{
14
    /**
15
     * @var int
16
     */
17
    private $id;
18
19
    /**
20
     * @var string
21
     */
22
    private $italic;
23
24
    /**
25
     * @var string
26
     */
27
    private $underline;
28
29
    /**
30
     * @var string
31
     */
32
    private $bold;
33
34
    /**
35
     * @var string
36
     */
37
    private $strikethrough;
38
39
    /**
40
     * @var string
41
     */
42
    private $name = 'Calibri';
43
44
    /**
45
     * @var int
46
     */
47
    private $size = 11;
48
49
    /**
50
     * @var string
51
     */
52
    private $color = '000000';
53
54
    /**
55
     * @param int $id
56
     * @return Font
57
     */
58 4
    public function setId($id)
59
    {
60 4
        $this->id = $id;
61 4
        return $this;
62
    }
63
64
    /**
65
     * @return int
66
     */
67 4
    public function getId()
68
    {
69 4
        return $this->id;
70
    }
71
72
    /**
73
     * @return Font
74
     */
75 1
    public function setItalic()
76
    {
77 1
        $this->italic = '<i/>';
78 1
        return $this;
79
    }
80
81
    /**
82
     * @return Font
83
     */
84 1
    public function setUnderline()
85
    {
86 1
        $this->underline = '<u/>';
87 1
        return $this;
88
    }
89
90
    /**
91
     * @return bool
92
     */
93 2
    public function isBold()
94
    {
95 2
        return null !== $this->bold;
96
    }
97
98
    /**
99
     * @return Font
100
     */
101 2
    public function setBold()
102
    {
103 2
        $this->bold = '<b/>';
104 2
        return $this;
105
    }
106
107
    /**
108
     * @return Font
109
     */
110 1
    public function setStrikethrough()
111
    {
112 1
        $this->strikethrough = '<s/>';
113 1
    }
114
115
    /**
116
     * @return string
117
     */
118 2
    public function getName()
119
    {
120 2
        return $this->name;
121
    }
122
123
    /**
124
     * @param string $name
125
     * @return Font
126
     */
127 1
    public function setName($name)
128
    {
129 1
        $this->name = $name;
130 1
        return $this;
131
    }
132
133
    /**
134
     * @return int
135
     */
136 2
    public function getSize()
137
    {
138 2
        return $this->size;
139
    }
140
141
    /**
142
     * @param int $size
143
     * @return Font
144
     */
145 1
    public function setSize($size)
146
    {
147 1
        $this->size = $size;
148 1
        return $this;
149
    }
150
151
    /**
152
     * @param string $color
153
     * @return Font
154
     */
155 2
    public function setColor($color)
156
    {
157 2
        $this->color = strtoupper($color);
158 2
        return $this;
159
    }
160
161
    /**
162
     * @return string
163
     */
164 5
    public function asXml()
165
    {
166 5
        return sprintf(
167 5
            StyleXml::FONT_DEFAULT_XML,
168 5
            $this->size,
169 5
            $this->color,
170 5
            $this->name,
171 5
            $this->bold,
172 5
            $this->italic,
173 5
            $this->underline,
174 5
            $this->strikethrough
175 5
        );
176
    }
177
}
178