Completed
Pull Request — develop (#263)
by Franck
11:48
created

Axis   A

Complexity

Total Complexity 16

Size/Duplication

Total Lines 220
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 92.86%

Importance

Changes 0
Metric Value
wmc 16
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 220
ccs 39
cts 42
cp 0.9286
rs 10

16 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getTitle() 0 4 1
A setTitle() 0 6 1
A getFont() 0 4 1
A setFont() 0 5 1
A getFormatCode() 0 4 1
A setFormatCode() 0 6 1
A getMajorGridlines() 0 4 1
A setMajorGridlines() 0 5 1
A getMinorGridlines() 0 4 1
A setMinorGridlines() 0 5 1
A getOutline() 0 4 1
A setOutline() 0 5 1
A getHashCode() 0 4 1
A getHashIndex() 0 4 1
A setHashIndex() 0 5 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
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 Outline
65
     */
66
    protected $outline;
67
68
    /**
69
     * Create a new \PhpOffice\PhpPresentation\Shape\Chart\Axis instance
70
     *
71
     * @param string $title Title
72
     */
73 65
    public function __construct($title = 'Axis Title')
74
    {
75 65
        $this->title = $title;
76 65
        $this->font  = new Font();
77 65
        $this->outline = new Outline();
78 65
    }
79
80
    /**
81
     * Get Title
82
     *
83
     * @return string
84
     */
85 22
    public function getTitle()
86
    {
87 22
        return $this->title;
88
    }
89
90
    /**
91
     * Set Title
92
     *
93
     * @param  string                         $value
94
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
95
     */
96 1
    public function setTitle($value = 'Axis Title')
97
    {
98 1
        $this->title = $value;
99
100 1
        return $this;
101
    }
102
103
    /**
104
     * Get font
105
     *
106
     * @return \PhpOffice\PhpPresentation\Style\Font
107
     */
108 43
    public function getFont()
109
    {
110 43
        return $this->font;
111
    }
112
113
    /**
114
     * Set font
115
     *
116
     * @param  \PhpOffice\PhpPresentation\Style\Font               $pFont Font
117
     * @throws \Exception
118
     * @return \PhpOffice\PhpPresentation\Shape\RichText\Paragraph
119
     */
120 1
    public function setFont(Font $pFont = null)
121
    {
122 1
        $this->font = $pFont;
123 1
        return $this;
124
    }
125
126
    /**
127
     * Get Format Code
128
     *
129
     * @return string
130
     */
131 21
    public function getFormatCode()
132
    {
133 21
        return $this->formatCode;
134
    }
135
136
    /**
137
     * Set Format Code
138
     *
139
     * @param  string                         $value
140
     * @return \PhpOffice\PhpPresentation\Shape\Chart\Axis
141
     */
142 1
    public function setFormatCode($value = '')
143
    {
144 1
        $this->formatCode = $value;
145
146 1
        return $this;
147
    }
148
149
    /**
150
     * @return Gridlines
151
     */
152 43
    public function getMajorGridlines()
153
    {
154 43
        return $this->majorGridlines;
155
    }
156
157
    /**
158
     * @param Gridlines $majorGridlines
159
     * @return Axis
160
     */
161 3
    public function setMajorGridlines(Gridlines $majorGridlines)
162
    {
163 3
        $this->majorGridlines = $majorGridlines;
164 3
        return $this;
165
    }
166
167
    /**
168
     * @return Gridlines
169
     */
170 43
    public function getMinorGridlines()
171
    {
172 43
        return $this->minorGridlines;
173
    }
174
175
    /**
176
     * @param Gridlines $minorGridlines
177
     * @return Axis
178
     */
179 3
    public function setMinorGridlines(Gridlines $minorGridlines)
180
    {
181 3
        $this->minorGridlines = $minorGridlines;
182 3
        return $this;
183
    }
184
185
    /**
186
     * @return Outline
187
     */
188 20
    public function getOutline()
189
    {
190 20
        return $this->outline;
191
    }
192
193
    /**
194
     * @param Outline $outline
195
     * @return Axis
196
     */
197
    public function setOutline($outline)
198
    {
199
        $this->outline = $outline;
200
        return $this;
201
    }
202
203
    /**
204
     * Get hash code
205
     *
206
     * @return string Hash code
207
     */
208 47
    public function getHashCode()
209
    {
210 47
        return md5($this->title . $this->formatCode . __CLASS__);
211
    }
212
213
    /**
214
     * Hash index
215
     *
216
     * @var string
217
     */
218
    private $hashIndex;
219
220
    /**
221
     * Get hash index
222
     *
223
     * Note that this index may vary during script execution! Only reliable moment is
224
     * while doing a write of a workbook and when changes are not allowed.
225
     *
226
     * @return string Hash index
227
     */
228 1
    public function getHashIndex()
229
    {
230 1
        return $this->hashIndex;
231
    }
232
233
    /**
234
     * Set hash index
235
     *
236
     * Note that this index may vary during script execution! Only reliable moment is
237
     * while doing a write of a workbook and when changes are not allowed.
238
     *
239
     * @param string $value Hash index
240
     */
241 1
    public function setHashIndex($value)
242
    {
243 1
        $this->hashIndex = $value;
244 1
        return $this;
245
    }
246
}
247