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

Font::__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 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
     * @return Font
51
     */
52
    public function setItalic()
53
    {
54
        $this->italic = '<i/>';
55
        return $this;
56
    }
57
58
    /**
59
     * @return Font
60
     */
61
    public function setUnderline()
62
    {
63
        $this->underline = '<u/>';
64
        return $this;
65
    }
66
67
    /**
68
     * @return bool
69
     */
70 2
    public function isBold()
71
    {
72 2
        return null !== $this->bold;
73
    }
74
75
    /**
76
     * @return Font
77
     */
78
    public function setBold()
79
    {
80
        $this->bold = '<b/>';
81
        return $this;
82
    }
83
84
    /**
85
     * @return Font
86
     */
87
    public function setStrikethrough()
88
    {
89
        $this->strikethrough = '<s/>';
90
    }
91
92
    /**
93
     * @return string
94
     */
95 2
    public function getName()
96
    {
97 2
        return $this->name;
98
    }
99
100
    /**
101
     * @param string $name
102
     * @return Font
103
     */
104
    public function setName($name)
105
    {
106
        $this->name = $name;
107
        return $this;
108
    }
109
110
    /**
111
     * @return int
112
     */
113 2
    public function getSize()
114
    {
115 2
        return $this->size;
116
    }
117
118
    /**
119
     * @param int $size
120
     * @return Font
121
     */
122
    public function setSize($size)
123
    {
124
        $this->size = $size;
125
        return $this;
126
    }
127
128
    /**
129
     * @param string $color
130
     * @return Font
131
     */
132
    public function setColor($color)
133
    {
134
        $this->color = $color;
135
        return $this;
136
    }
137
138
    /**
139
     * @return string
140
     */
141 2
    public function asXml()
142
    {
143 2
        return sprintf(
144 2
            StyleXml::FONT_DEFAULT_XML,
145 2
            $this->size,
146 2
            $this->color,
147 2
            $this->name,
148 2
            $this->bold,
149 2
            $this->italic,
150 2
            $this->underline,
151 2
            $this->strikethrough
152 2
        );
153
    }
154
}
155