Completed
Pull Request — develop (#263)
by Franck
08:26
created

Axis::getOutline()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4
 * presentations documents.
5
 *
6
 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7
 * General Public License version 3 as published by the Free Software Foundation.
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code. For the full list of
11
 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12
 *
13
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
18
namespace PhpOffice\PhpPresentation\Shape\Chart;
19
20
use PhpOffice\PhpPresentation\ComparableInterface;
21
use PhpOffice\PhpPresentation\Style\Font;
22
use PhpOffice\PhpPresentation\Style\Outline;
23
24
/**
25
 * \PhpOffice\PhpPresentation\Shape\Chart\Axis
26
 */
27
class Axis implements ComparableInterface
28
{
29
    const AXIS_X = 'x';
30
    const AXIS_Y = 'y';
31
32
    /**
33
     * Title
34
     *
35
     * @var string
36
     */
37
    private $title = 'Axis Title';
38
39
    /**
40
     * Format code
41
     *
42
     * @var string
43
     */
44
    private $formatCode = '';
45
46
    /**
47
     * Font
48
     *
49
     * @var \PhpOffice\PhpPresentation\Style\Font
50
     */
51
    private $font;
52
53
    /**
54
     * @var Gridlines
55
     */
56
    protected $majorGridlines;
57
58
    /**
59
     * @var Gridlines
60
     */
61
    protected $minorGridlines;
62
63
    /**
64
     * @var int
65
     */
66
    protected $minBounds;
67
68
    /**
69
     * @var int
70
     */
71
    protected $maxBounds;
72
73
    /**
74
     * @var Outline
75
     */
76
    protected $outline;
77 69
78
    /**
79 69
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
80 69
     *
81 69
     * @param string $title Title
82
     */
83
    public function __construct($title = 'Axis Title')
84
    {
85
        $this->title = $title;
86
        $this->font  = new Font();
87
    }
88 23
89
    /**
90 23
     * Get Title
91
     *
92
     * @return string
93
     */
94
    public function getTitle()
95
    {
96
        return $this->title;
97
    }
98
99 1
    /**
100
     * Set Title
101 1
     *
102
     * @param  string                         $value
103 1
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
104
     */
105
    public function setTitle($value = 'Axis Title')
106
    {
107
        $this->title = $value;
108
109
        return $this;
110
    }
111 46
112
    /**
113 46
     * Get font
114
     *
115
     * @return \PhpOffice\PhpPresentation\Style\Font
116
     */
117
    public function getFont()
118
    {
119
        return $this->font;
120
    }
121
122
    /**
123 1
     * Set font
124
     *
125 1
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
126 1
     * @throws \Exception
127
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
128
     */
129
    public function setFont(Font $pFont = null)
130
    {
131
        $this->font = $pFont;
132
        return $this;
133
    }
134 22
135
    /**
136 22
     * Get Format Code
137
     *
138
     * @return string
139
     */
140
    public function getFormatCode()
141
    {
142
        return $this->formatCode;
143
    }
144
145 1
    /**
146
     * Set Format Code
147 1
     *
148
     * @param  string                         $value
149 1
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
150
     */
151
    public function setFormatCode($value = '')
152
    {
153
        $this->formatCode = $value;
154
155 46
        return $this;
156
    }
157 46
158
    /**
159
     * @return Gridlines
160
     */
161
    public function getMajorGridlines()
162
    {
163
        return $this->majorGridlines;
164 3
    }
165
166 3
    /**
167 3
     * @param Gridlines $majorGridlines
168
     * @return Axis
169
     */
170
    public function setMajorGridlines(Gridlines $majorGridlines)
171
    {
172
        $this->majorGridlines = $majorGridlines;
173 46
        return $this;
174
    }
175 46
176
    /**
177
     * @return Gridlines
178
     */
179
    public function getMinorGridlines()
180
    {
181
        return $this->minorGridlines;
182 3
    }
183
184 3
    /**
185 3
     * @param Gridlines $minorGridlines
186
     * @return Axis
187
     */
188
    public function setMinorGridlines(Gridlines $minorGridlines)
189
    {
190
        $this->minorGridlines = $minorGridlines;
191 45
        return $this;
192
    }
193 45
194
    /**
195
     * @return int|null
196
     */
197
    public function getMinBounds()
198
    {
199
        return $this->minBounds;
200 3
    }
201
202 3
    /**
203 3
     * @param int|null $minBounds
204
     * @return Axis
205
     */
206
    public function setMinBounds($minBounds = null)
207
    {
208
        $this->minBounds = is_null($minBounds) ? null : (int) $minBounds;
209 45
        return $this;
210
    }
211 45
212
    /**
213
     * @return int|null
214
     */
215
    public function getMaxBounds()
216
    {
217
        return $this->maxBounds;
218 3
    }
219
220 3
    /**
221 3
     * @param int|null $maxBounds
222
     * @return Axis
223
     */
224
    public function setMaxBounds($maxBounds = null)
225
    {
226
        $this->maxBounds = is_null($maxBounds) ? null : (int) $maxBounds;
227
        return $this;
228
    }
229 50
230
    /**
231 50
     * @return Outline
232
     */
233
    public function getOutline()
234
    {
235
        return $this->outline;
236
    }
237
238
    /**
239
     * @param Outline $outline
240
     * @return Axis
241
     */
242
    public function setOutline($outline)
243
    {
244
        $this->outline = $outline;
245
        return $this;
246
    }
247
248
    /**
249 1
     * Get hash code
250
     *
251 1
     * @return string Hash code
252
     */
253
    public function getHashCode()
254
    {
255
        return md5($this->title . $this->formatCode . __CLASS__);
256
    }
257
258
    /**
259
     * Hash index
260
     *
261
     * @var string
262 1
     */
263
    private $hashIndex;
264 1
265 1
    /**
266
     * Get hash index
267
     *
268 1
     * Note that this index may vary during script execution! Only reliable moment is
269
     * while doing a write of a workbook and when changes are not allowed.
270
     *
271
     * @return string Hash index
272
     */
273
    public function getHashIndex()
274
    {
275
        return $this->hashIndex;
276
    }
277
278
    /**
279
     * Set hash index
280
     *
281
     * Note that this index may vary during script execution! Only reliable moment is
282
     * while doing a write of a workbook and when changes are not allowed.
283
     *
284
     * @param string $value Hash index
285
     */
286
    public function setHashIndex($value)
287
    {
288
        $this->hashIndex = $value;
289
        return $this;
290
    }
291
}
292