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

Font::setSize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 5
ccs 0
cts 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 2
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
13
{
14
    /**
15
     * @var string
16
     */
17
    private $italic;
18
19
    /**
20
     * @var string
21
     */
22
    private $underline;
23
24
    /**
25
     * @var string
26
     */
27
    private $bold;
28
29
    /**
30
     * @var string
31
     */
32
    private $strikethrough;
33
34
    /**
35
     * @var string
36
     */
37
    private $name = 'Calibri';
38
39
    /**
40
     * @var int
41
     */
42
    private $size = 11;
43
44
    /**
45
     * @var string
46
     */
47
    private $color = '000000';
48
49
    /**
50
     * @var Style
51
     */
52
    private $style;
53
54
    /**
55
     * Font constructor.
56
     *
57
     * @param Style $style
58
     */
59 3
    public function __construct(Style $style)
60
    {
61 3
        $this->style = $style;
62 3
    }
63
64
    /**
65
     * @return Style
66
     */
67
    public function style()
68
    {
69
        return $this->style;
70
    }
71
72
    /**
73
     * @return Font
74
     */
75
    public function setItalic()
76
    {
77
        $this->italic = '<i/>';
78
        return $this;
79
    }
80
81
    /**
82
     * @return Font
83
     */
84
    public function setUnderline()
85
    {
86
        $this->underline = '<u/>';
87
        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
    public function setBold()
102
    {
103
        $this->bold = '<b/>';
104
        return $this;
105
    }
106
107
    /**
108
     * @return Font
109
     */
110
    public function setStrikethrough()
111
    {
112
        $this->strikethrough = '<s/>';
113
    }
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
    public function setName($name)
128
    {
129
        $this->name = $name;
130
        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
    public function setSize($size)
146
    {
147
        $this->size = $size;
148
        return $this;
149
    }
150
151
    /**
152
     * @param string $color
153
     * @return Font
154
     */
155
    public function setColor($color)
156
    {
157
        $this->color = $color;
158
        return $this;
159
    }
160
161
    /**
162
     * @return string
163
     */
164 2
    public function asXml()
165
    {
166 2
        return sprintf(
167 2
            StyleXml::FONT_DEFAULT_XML,
168 2
            $this->size,
169 2
            $this->color,
170 2
            $this->name,
171 2
            $this->bold,
172 2
            $this->italic,
173 2
            $this->underline,
174 2
            $this->strikethrough
175 2
        );
176
    }
177
}
178