Completed
Pull Request — develop (#333)
by Franck
08:40
created

Axis::getMinBounds()   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 0
Metric Value
c 0
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
 * 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
23
/**
24
 * \PhpOffice\PhpPresentation\Shape\Chart\Axis
25
 */
26
class Axis implements ComparableInterface
27
{
28
    const AXIS_X = 'x';
29
    const AXIS_Y = 'y';
30
31
    /**
32
     * Title
33
     *
34
     * @var string
35
     */
36
    private $title = 'Axis Title';
37
38
    /**
39
     * Format code
40
     *
41
     * @var string
42
     */
43
    private $formatCode = '';
44
45
    /**
46
     * Font
47
     *
48
     * @var \PhpOffice\PhpPresentation\Style\Font
49
     */
50
    private $font;
51
52
    /**
53
     * @var Gridlines
54
     */
55
    protected $majorGridlines;
56
57
    /**
58
     * @var Gridlines
59
     */
60
    protected $minorGridlines;
61
62
    /**
63
     * @var int
64
     */
65
    protected $minBounds;
66
67
    /**
68
     * @var int
69
     */
70
    protected $maxBounds;
71
72
    /**
73
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
74
     *
75
     * @param string $title Title
76
     */
77 69
    public function __construct($title = 'Axis Title')
78
    {
79 69
        $this->title = $title;
80 69
        $this->font  = new Font();
81 69
    }
82
83
    /**
84
     * Get Title
85
     *
86
     * @return string
87
     */
88 23
    public function getTitle()
89
    {
90 23
        return $this->title;
91
    }
92
93
    /**
94
     * Set Title
95
     *
96
     * @param  string                         $value
97
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
98
     */
99 1
    public function setTitle($value = 'Axis Title')
100
    {
101 1
        $this->title = $value;
102
103 1
        return $this;
104
    }
105
106
    /**
107
     * Get font
108
     *
109
     * @return \PhpOffice\PhpPresentation\Style\Font
110
     */
111 46
    public function getFont()
112
    {
113 46
        return $this->font;
114
    }
115
116
    /**
117
     * Set font
118
     *
119
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
120
     * @throws \Exception
121
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
122
     */
123 1
    public function setFont(Font $pFont = null)
124
    {
125 1
        $this->font = $pFont;
126 1
        return $this;
127
    }
128
129
    /**
130
     * Get Format Code
131
     *
132
     * @return string
133
     */
134 22
    public function getFormatCode()
135
    {
136 22
        return $this->formatCode;
137
    }
138
139
    /**
140
     * Set Format Code
141
     *
142
     * @param  string                         $value
143
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
144
     */
145 1
    public function setFormatCode($value = '')
146
    {
147 1
        $this->formatCode = $value;
148
149 1
        return $this;
150
    }
151
152
    /**
153
     * @return Gridlines
154
     */
155 46
    public function getMajorGridlines()
156
    {
157 46
        return $this->majorGridlines;
158
    }
159
160
    /**
161
     * @param Gridlines $majorGridlines
162
     * @return Axis
163
     */
164 3
    public function setMajorGridlines(Gridlines $majorGridlines)
165
    {
166 3
        $this->majorGridlines = $majorGridlines;
167 3
        return $this;
168
    }
169
170
    /**
171
     * @return Gridlines
172
     */
173 46
    public function getMinorGridlines()
174
    {
175 46
        return $this->minorGridlines;
176
    }
177
178
    /**
179
     * @param Gridlines $minorGridlines
180
     * @return Axis
181
     */
182 3
    public function setMinorGridlines(Gridlines $minorGridlines)
183
    {
184 3
        $this->minorGridlines = $minorGridlines;
185 3
        return $this;
186
    }
187
188
    /**
189
     * @return int|null
190
     */
191 45
    public function getMinBounds()
192
    {
193 45
        return $this->minBounds;
194
    }
195
196
    /**
197
     * @param int|null $minBounds
198
     * @return Axis
199
     */
200 3
    public function setMinBounds($minBounds = null)
201
    {
202 3
        $this->minBounds = is_null($minBounds) ? null : (int) $minBounds;
203 3
        return $this;
204
    }
205
206
    /**
207
     * @return int|null
208
     */
209 45
    public function getMaxBounds()
210
    {
211 45
        return $this->maxBounds;
212
    }
213
214
    /**
215
     * @param int|null $maxBounds
216
     * @return Axis
217
     */
218 3
    public function setMaxBounds($maxBounds = null)
219
    {
220 3
        $this->maxBounds = is_null($maxBounds) ? null : (int) $maxBounds;
221 3
        return $this;
222
    }
223
224
    /**
225
     * Get hash code
226
     *
227
     * @return string Hash code
228
     */
229 50
    public function getHashCode()
230
    {
231 50
        return md5($this->title . $this->formatCode . __CLASS__);
232
    }
233
234
    /**
235
     * Hash index
236
     *
237
     * @var string
238
     */
239
    private $hashIndex;
240
241
    /**
242
     * Get hash index
243
     *
244
     * Note that this index may vary during script execution! Only reliable moment is
245
     * while doing a write of a workbook and when changes are not allowed.
246
     *
247
     * @return string Hash index
248
     */
249 1
    public function getHashIndex()
250
    {
251 1
        return $this->hashIndex;
252
    }
253
254
    /**
255
     * Set hash index
256
     *
257
     * Note that this index may vary during script execution! Only reliable moment is
258
     * while doing a write of a workbook and when changes are not allowed.
259
     *
260
     * @param string $value Hash index
261
     */
262 1
    public function setHashIndex($value)
263
    {
264 1
        $this->hashIndex = $value;
265 1
        return $this;
266
    }
267
}
268