Failed Conditions
Pull Request — master (#3876)
by Abdul Malik
22:45 queued 13:31
created

SpContainer   A

Complexity

Total Complexity 27

Size/Duplication

Total Lines 288
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 27
eloc 44
dl 0
loc 288
ccs 57
cts 57
cp 1
rs 10
c 0
b 0
f 0

26 Methods

Rating   Name   Duplication   Size   Complexity  
A getSpFlag() 0 3 1
A setSpFlag() 0 3 1
A getParent() 0 3 1
A setSpgr() 0 3 1
A setSpType() 0 3 1
A setOPT() 0 3 1
A getSpId() 0 3 1
A setSpId() 0 3 1
A setParent() 0 3 1
A getSpType() 0 3 1
A getSpgr() 0 3 1
A getOPT() 0 3 1
A setEndOffsetY() 0 3 1
A setEndCoordinates() 0 3 1
A getStartCoordinates() 0 3 1
A getNestingLevel() 0 11 2
A getStartOffsetX() 0 3 1
A setStartOffsetY() 0 3 1
A getEndCoordinates() 0 3 1
A setEndOffsetX() 0 3 1
A getEndOffsetY() 0 3 1
A setStartCoordinates() 0 3 1
A setStartOffsetX() 0 3 1
A getOPTCollection() 0 3 1
A getStartOffsetY() 0 3 1
A getEndOffsetX() 0 3 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer;
4
5
use PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer\SpgrContainer;
6
7
class SpContainer
8
{
9
    /**
10
     * Parent Shape Group Container.
11
     */
12
    private SpgrContainer $parent;
13
14
    /**
15
     * Is this a group shape?
16
     */
17
    private bool $spgr = false;
18
19
    /**
20
     * Shape type.
21
     */
22
    private int $spType;
23
24
    /**
25
     * Shape flag.
26
     */
27
    private int $spFlag;
28
29
    /**
30
     * Shape index (usually group shape has index 0, and the rest: 1,2,3...).
31
     */
32
    private int $spId;
33
34
    /**
35
     * Array of options.
36
     */
37
    private array $OPT = [];
38
39
    /**
40
     * Cell coordinates of upper-left corner of shape, e.g. 'A1'.
41
     */
42
    private string $startCoordinates = '';
43
44
    /**
45
     * Horizontal offset of upper-left corner of shape measured in 1/1024 of column width.
46
     */
47
    private int|float $startOffsetX;
48
49
    /**
50
     * Vertical offset of upper-left corner of shape measured in 1/256 of row height.
51
     */
52
    private int|float $startOffsetY;
53
54
    /**
55
     * Cell coordinates of bottom-right corner of shape, e.g. 'B2'.
56
     */
57
    private string $endCoordinates;
58
59
    /**
60
     * Horizontal offset of bottom-right corner of shape measured in 1/1024 of column width.
61
     */
62
    private int|float $endOffsetX;
63
64
    /**
65
     * Vertical offset of bottom-right corner of shape measured in 1/256 of row height.
66
     */
67
    private int|float $endOffsetY;
68
69
    /**
70
     * Set parent Shape Group Container.
71
     */
72 25
    public function setParent(SpgrContainer $parent): void
73
    {
74 25
        $this->parent = $parent;
75
    }
76
77
    /**
78
     * Get the parent Shape Group Container.
79
     */
80 11
    public function getParent(): SpgrContainer
81
    {
82 11
        return $this->parent;
83
    }
84
85
    /**
86
     * Set whether this is a group shape.
87
     */
88 14
    public function setSpgr(bool $value): void
89
    {
90 14
        $this->spgr = $value;
91
    }
92
93
    /**
94
     * Get whether this is a group shape.
95
     */
96 14
    public function getSpgr(): bool
97
    {
98 14
        return $this->spgr;
99
    }
100
101
    /**
102
     * Set the shape type.
103
     */
104 14
    public function setSpType(int $value): void
105
    {
106 14
        $this->spType = $value;
107
    }
108
109
    /**
110
     * Get the shape type.
111
     */
112 14
    public function getSpType(): int
113
    {
114 14
        return $this->spType;
115
    }
116
117
    /**
118
     * Set the shape flag.
119
     */
120 14
    public function setSpFlag(int $value): void
121
    {
122 14
        $this->spFlag = $value;
123
    }
124
125
    /**
126
     * Get the shape flag.
127
     */
128 14
    public function getSpFlag(): int
129
    {
130 14
        return $this->spFlag;
131
    }
132
133
    /**
134
     * Set the shape index.
135
     */
136 14
    public function setSpId(int $value): void
137
    {
138 14
        $this->spId = $value;
139
    }
140
141
    /**
142
     * Get the shape index.
143
     */
144 14
    public function getSpId(): int
145
    {
146 14
        return $this->spId;
147
    }
148
149
    /**
150
     * Set an option for the Shape Group Container.
151
     *
152
     * @param int $property The number specifies the option
153
     */
154 20
    public function setOPT(int $property, mixed $value): void
155
    {
156 20
        $this->OPT[$property] = $value;
157
    }
158
159
    /**
160
     * Get an option for the Shape Group Container.
161
     *
162
     * @param int $property The number specifies the option
163
     */
164 11
    public function getOPT(int $property): mixed
165
    {
166 11
        return $this->OPT[$property] ?? null;
167
    }
168
169
    /**
170
     * Get the collection of options.
171
     */
172 14
    public function getOPTCollection(): array
173
    {
174 14
        return $this->OPT;
175
    }
176
177
    /**
178
     * Set cell coordinates of upper-left corner of shape.
179
     *
180
     * @param string $value eg: 'A1'
181
     */
182 20
    public function setStartCoordinates(string $value): void
183
    {
184 20
        $this->startCoordinates = $value;
185
    }
186
187
    /**
188
     * Get cell coordinates of upper-left corner of shape.
189
     */
190 20
    public function getStartCoordinates(): string
191
    {
192 20
        return $this->startCoordinates;
193
    }
194
195
    /**
196
     * Set offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
197
     */
198 20
    public function setStartOffsetX(int|float $startOffsetX): void
199
    {
200 20
        $this->startOffsetX = $startOffsetX;
201
    }
202
203
    /**
204
     * Get offset in x-direction of upper-left corner of shape measured in 1/1024 of column width.
205
     */
206 20
    public function getStartOffsetX(): int|float
207
    {
208 20
        return $this->startOffsetX;
209
    }
210
211
    /**
212
     * Set offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
213
     */
214 20
    public function setStartOffsetY(int|float $startOffsetY): void
215
    {
216 20
        $this->startOffsetY = $startOffsetY;
217
    }
218
219
    /**
220
     * Get offset in y-direction of upper-left corner of shape measured in 1/256 of row height.
221
     */
222 20
    public function getStartOffsetY(): int|float
223
    {
224 20
        return $this->startOffsetY;
225
    }
226
227
    /**
228
     * Set cell coordinates of bottom-right corner of shape.
229
     *
230
     * @param string $value eg: 'A1'
231
     */
232 20
    public function setEndCoordinates(string $value): void
233
    {
234 20
        $this->endCoordinates = $value;
235
    }
236
237
    /**
238
     * Get cell coordinates of bottom-right corner of shape.
239
     */
240 20
    public function getEndCoordinates(): string
241
    {
242 20
        return $this->endCoordinates;
243
    }
244
245
    /**
246
     * Set offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
247
     */
248 20
    public function setEndOffsetX(int|float $endOffsetX): void
249
    {
250 20
        $this->endOffsetX = $endOffsetX;
251
    }
252
253
    /**
254
     * Get offset in x-direction of bottom-right corner of shape measured in 1/1024 of column width.
255
     */
256 20
    public function getEndOffsetX(): int|float
257
    {
258 20
        return $this->endOffsetX;
259
    }
260
261
    /**
262
     * Set offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
263
     */
264 20
    public function setEndOffsetY(int|float $endOffsetY): void
265
    {
266 20
        $this->endOffsetY = $endOffsetY;
267
    }
268
269
    /**
270
     * Get offset in y-direction of bottom-right corner of shape measured in 1/256 of row height.
271
     */
272 20
    public function getEndOffsetY(): int|float
273
    {
274 20
        return $this->endOffsetY;
275
    }
276
277
    /**
278
     * Get the nesting level of this spContainer. This is the number of spgrContainers between this spContainer and
279
     * the dgContainer. A value of 1 = immediately within first spgrContainer
280
     * Higher nesting level occurs if and only if spContainer is part of a shape group.
281
     *
282
     * @return int Nesting level
283
     */
284 11
    public function getNestingLevel(): int
285
    {
286 11
        $nestingLevel = 0;
287
288 11
        $parent = $this->getParent();
289 11
        while ($parent instanceof SpgrContainer) {
290 11
            ++$nestingLevel;
291 11
            $parent = $parent->getParent();
292
        }
293
294 11
        return $nestingLevel;
295
    }
296
}
297