Completed
Push — master ( 94f348...ce557b )
by Marko
02:44
created

Geometry   C

Complexity

Total Complexity 78

Size/Duplication

Total Lines 594
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 29.88%

Importance

Changes 0
Metric Value
wmc 78
lcom 1
cbo 2
dl 0
loc 594
ccs 49
cts 164
cp 0.2988
rs 5.4563
c 0
b 0
f 0

35 Methods

Rating   Name   Duplication   Size   Complexity  
A getScripts() 0 4 1
A hasDOMAttributes() 0 4 1
B removeDefaultDOMAttributes() 0 8 7
A getDOMAttributes() 0 5 1
A buffer() 0 4 1
A skipCache() 0 4 1
A radiusTubular() 0 4 1
A radiusBottom() 0 4 1
A radiusTop() 0 4 1
A segments() 0 4 1
A segmentsRadial() 0 4 1
A segmentsWidth() 0 4 1
A segmentsTheta() 0 4 1
A segmentsPhi() 0 4 1
A segmentsTubular() 0 4 1
A phiStart() 0 4 1
A phiLength() 0 4 1
A radiusInner() 0 4 1
A radiusOuter() 0 4 1
A arc() 0 4 1
A p() 0 4 1
A q() 0 4 1
B __call() 0 21 5
D isPrimitiveMethod() 0 35 19
C primitive() 0 25 7
A width() 0 4 1
A height() 0 4 1
A depth() 0 4 1
A radius() 0 4 1
A thetaStart() 0 4 1
A thetaLength() 0 4 1
A openEnded() 0 4 1
A segmentsHeight() 0 4 1
A translate() 0 4 1
D primitiveDefaults() 0 35 10

How to fix   Complexity   

Complex Class

Complex classes like Geometry often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes. You can also have a look at the cohesion graph to spot any un-connected, or weakly-connected components.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use Geometry, and based on these observations, apply Extract Interface, too.

1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 12:20:44 AM
5
 * Contact      [email protected]
6
 * @copyright   2016 Marko Kungla - https://github.com/mkungla
7
 * @license     The MIT License (MIT)
8
 * 
9
 * @category       AframeVR
10
 * @package        aframe-php
11
 * 
12
 * Lang         PHP (php version >= 7)
13
 * Encoding     UTF-8
14
 * File         Geometry.php
15
 * Code format  PSR-2 and 12
16
 * @link        https://github.com/mkungla/aframe-php
17
 ^ @issues      https://github.com/mkungla/aframe-php/issues
18
 * ********************************************************************
19
 * Contributors:
20
 * @author Marko Kungla <[email protected]>
21
 * ********************************************************************
22
 * Comments:
23
 * @formatter:on */
24
namespace AframeVR\Components;
25
26
use \AframeVR\Interfaces\ComponentInterface;
27
use \AframeVR\Core\Exceptions\{
28
    InvalidComponentArgumentException,
29
    InvalidComponentMethodException
30
};
31
use \DOMAttr;
32
33
/**
34
 * The geometry component provides a basic shape for an entity.
35
 * The general geometry is defined by the primitive property.
36
 * Geometric primitives, in computer graphics, means an extremely basic shape. With the primitive defined,
37
 * additional properties are used to further define the geometry. A material component is usually defined alongside
38
 * to provide a appearance alongside the shape to create a complete mesh.
39
 */
40
class Geometry implements ComponentInterface
41
{
42
43
    const ALLOWED_PRIMITIVES = array(
44
        'box',
45
        'circle',
46
        'cone',
47
        'cylinder',
48
        'plane',
49
        'ring',
50
        'sphere',
51
        'torus',
52
        'torusKnot'
53
    );
54
55
    /**
56
     * Properties based on primitive
57
     */
58
    const P_COMMON_PROPS = array(
59
60
        /* One of box, circle, cone, cylinder, plane, ring, sphere, torus, torusKnot. */
61
        'primitive' => null,
62
63
        /* The translate property translates the geometry. It is provided as a vec3. This is a useful short-hand for 
64
         * translating the geometry to effectively move its pivot point when running animations. */
65
        'translate' => '0 1 0'
66
    );
67
68
    /**
69
     * The box primitive defines boxes (i.e., any quadilateral, not just cubes).
70
     */
71
    const P_BOX = array(
72
        /* Width (in meters) of the sides on the X axis. */
73
        'width' => 1,
74
        /* Height (in meters) of the sides on the Y axis. */
75
        'height' => 1,
76
        /* Depth (in meters) of the sides on the Z axis. */
77
        'depth' => 1
78
    );
79
80
    /**
81
     * The circle primitive defines two-dimensional circles, which can be complete circles or partial circles (like Pac-Man).
82
     * Note that because it is flat, only a single side of the circle will be rendered if “side: double” is not specified on the material component.
83
     */
84
    const P_CIRCLE = array(
85
        /* Radius (in meters) of the circle. */
86
        'radius' => 1,
87
        /* Number of triangles to construct the circle, like pizza slices. A higher number of segments means the circle will be more round. */
88
        'segments' => 32,
89
        /* Start angle for first segment. Can be used to define a partial circle. */
90
        'thetaStart' => 0,
91
        /* The central angle (in degrees). Defaults to 360, which makes for a complete circle. */
92
        'thetaLength' => 360
93
    );
94
95
    /**
96
     * The cone primitive under the hood is a cylinder primitive with varying top and bottom radiuses.
97
     */
98
    const P_CONE = array(
99
        /* Height of the cone. */
100
        'height' => 2,
101
        /* Whether the ends of the cone are open (true) or capped ('false'). */
102
        'openEnded' => 'false',
103
        /* Radius of the bottom end of the cone. */
104
        'radiusBottom' => 1,
105
        /* Radius of the top end of the cone. */
106
        'radiusTop' => 1,
107
        /* Number of segmented faces around the circumference of the cone. */
108
        'segmentsRadial' => 36,
109
        /* Number of rows of faces along the height of the cone. */
110
        'segmentsHeight' => 18,
111
        /* Starting angle in degrees. */
112
        'thetaStart' => 0,
113
        /* Central angle in degrees. */
114
        'thetaLength' => 360
115
    );
116
117
    /**
118
     * The cylinder primitive can define cylinders in the traditional sense like a Coca-Cola™ can,
119
     * but it can also define shapes such as tubes and curved surfaces.
120
     * We’ll go over some of these cylinder recipes below.
121
     * 1. Traditional cylinders can be defined by using only a height and a radius:
122
     * 2. Tubes can be defined by making the cylinder open-ended, which removes the top and bottom surfaces of the cylinder such that the inside is visible.
123
     * A double-sided material will be needed to render properly:
124
     * 3. Curved surfaces can be defined by specifying the angle via thetaLength such that the cylinder doesn’t curve all the way around,
125
     * making the cylinder open-ended, and then making the material double-sided.
126
     * 4. Other types of prisms can be defined by varying the number of radial segments (i.e., sides). For example, to make a hexagonal prism:
127
     */
128
    const P_CYLINDER = array(
129
        /* Radius of the cylinder. */
130
        'height' => 3,
131
        /* Height of the cylinder. */
132
        'radius' => 2,
133
        /* Number of segmented faces around the circumference of the cylinder. */
134
        'segmentsRadial' => 36,
135
        /* Number of rows of faces along the height of the cylinder. */
136
        'segmentsHeight' => 18,
137
        /* Whether the ends of the cylinder are open (true) or capped ('false'). */
138
        'openEnded' => 'false',
139
        /* Starting angle in degrees. */
140
        'thetaStart' => 0,
141
        /* Central angle in degrees. */
142
        'thetaLength' => 360
143
    );
144
145
    /**
146
     * The plane primitive defines a flat surface.
147
     * Note that because it is flat,
148
     * only a single side of the plane will be rendered if side: double is not specified on the material component.
149
     */
150
    const P_PLANE = array(
151
        /* Width along the X axis. */
152
        'width' => 1,
153
        /* Height along the Y axis. */
154
        'height' => 1
155
    );
156
157
    /**
158
     * The ring geometry defines a flat ring, like a CD.
159
     * Note that because it is flat,
160
     * only a single side of the ring will be rendered if side: double is not specified on the material component.
161
     */
162
    const P_RING = array(
163
        /* Radius of the inner hole of the ring. */
164
        'radiusInner' => 1,
165
        /* Radius of the outer edge of the ring. */
166
        'radiusOuter' => 1,
167
        /* Number of segments. A higher number means the ring will be more round */
168
        'segmentsTheta' => 32,
169
        /* Number of triangles within each face defined by segmentsTheta. */
170
        'segmentsPhi' => 8,
171
        /* Starting angle in degrees. */
172
        'thetaStart' => 0,
173
        /* Central angle in degrees. */
174
        'thetaLength' => 360
175
    );
176
177
    /**
178
     * The sphere primitive can define spheres in the traditional sense like a basketball.
179
     *
180
     * But it can also define various polyhedrons and abstract shapes given that it can specify
181
     * the number of horizontal and vertical angles and faces.
182
     *
183
     * Sticking with a basic sphere, the default number of segments is high enough to make the sphere appear round.
184
     */
185
    const P_SPHERE = array(
186
        /* Radius of the sphere. */
187
        'radius' => 1,
188
        /* Number of horizontal segments. */
189
        'segmentsWidth' => 18,
190
        /* Number of vertical segments. */
191
        'segmentsHeight' => 36,
192
        /* Horizontal starting angle. */
193
        'phiStart' => 0,
194
        /* Horizontal sweep angle size. */
195
        'phiLength' => 360,
196
        /* Vertical starting angle. */
197
        'thetaStart' => 0,
198
        /* Vertical sweep angle size. */
199
        'thetaLength' => 360
200
    );
201
202
    /**
203
     * The torus primitive defines a donut shape.
204
     */
205
    const P_TORUS = array(
206
        /* Radius of the outer edge of the torus. */
207
        'radius' => 1,
208
        /* Radius of the tube. */
209
        'radiusTubular' => 0.2,
210
        /* Number of segments along the circumference of the tube ends. A higher number means the tube will be more round. */
211
        'segmentsRadial' => 36,
212
        /* Number of segments along the circumference of the tube face. A higher number means the tube will be more round. */
213
        'segmentsTubular' => 32,
214
        /* Central angle. */
215
        'arc' => 360
216
    );
217
218
    /**
219
     * The torus knot primitive defines a pretzel shape, the particular shape of which is defined by a pair of coprime integers,
220
     * p and q.
221
     * If p and q are not coprime the result will be a torus link.
222
     */
223
    const P_TORUS_KNOT = array(
224
        /* Radius that contains the torus knot. */
225
        'radius' => 1,
226
        /* Radius of the tubes of the torus knot. */
227
        'radiusTubular' => 0.2,
228
        /* Number of segments along the circumference of the tube ends. A higher number means the tube will be more round. */
229
        'segmentsRadial' => 36,
230
        /* Number of segments along the circumference of the tube face. A higher number means the tube will be more round. */
231
        'segmentsTubular' => 32,
232
        /* Number that helps define the pretzel shape. */
233
        'p' => 2,
234
        /* Number that helps define the pretzel shape. */
235
        'q' => 3
236
    );
237
238
    /* DOM atrributes */
239
    protected $primitive;
240
241
    protected $width;
242
243
    protected $height;
244
245
    protected $depth;
246
247
    protected $radius;
248
249
    protected $radiusTubular;
250
251
    protected $radiusBottom;
252
253
    protected $radiusTop;
254
255
    protected $segments;
256
257
    protected $thetaStart;
258
259
    protected $thetaLength;
260
261
    protected $openEnded;
262
263
    protected $segmentsRadial;
264
265
    protected $segmentsHeight;
266
267
    protected $segmentsWidth;
268
269
    protected $segmentsTheta;
270
271
    protected $segmentsPhi;
272
273
    protected $segmentsTubular;
274
275
    protected $phiStart;
276
277
    protected $phiLength;
278
279
    protected $radiusInner;
280
281
    protected $radiusOuter;
282
283
    protected $arc;
284
285
    protected $p;
286
287
    protected $q;
288
289
    protected $translate;
290
291
    /**
292
     * Get Component scripts
293
     *
294
     * {@inheritdoc}
295
     *
296
     * @return array
297
     */
298
    public function getScripts(): array
299
    {
300
        return array();
301
    }
302
303
    /**
304
     * Does component have DOM Atributes
305
     *
306
     * {@inheritdoc}
307
     *
308
     * @return bool
309
     */
310
    public function hasDOMAttributes(): bool
311
    {
312
        return ! empty(get_object_vars($this));
313
    }
314
315
    /**
316
     * Remove default DOMElement Attributes which are not required
317
     *
318
     * @return void
319
     */
320
    public function removeDefaultDOMAttributes()
321
    {
322
        $defaults = $this->primitiveDefaults();
323
        foreach (get_object_vars($this) as $name => $value) {
324
            if (empty($value) || (array_key_exists($name, self::P_COMMON_PROPS) && $value === self::P_COMMON_PROPS[$name]) || (array_key_exists($name, $defaults) && $value === $defaults[$name]))
325
                unset($this->$name);
326
        }
327
    }
328
329
    /**
330
     * Get DOMAttr for the entity
331
     *
332
     * @return DOMAttr
333
     */
334
    public function getDOMAttributes(): DOMAttr
335
    {
336
        $format = implode(': %s; ', array_keys(get_object_vars($this))) . ': %s;';
337
        return new DOMAttr('geometry', vsprintf($format, array_values(get_object_vars($this))));
338
    }
339
340
    /**
341
     * Set primitive
342
     *
343
     * One of box, circle, cone, cylinder, plane, ring, sphere, torus, torusKnot.
344
     *
345
     * @param unknown $primitive            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $primitive not be unknown|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
346
     * @throws InvalidComponentArgumentException
347
     */
348 8
    public function primitive($primitive = null)
349
    {
350
        try {
351 8
            if (in_array($primitive, self::ALLOWED_PRIMITIVES)) {
352
                /* If primitive is changed we reset the object and releoad allowed attributes */
353 8
                $this->primitive = $primitive;
354 8
                $defaults = $this->primitiveDefaults();
355 8
                foreach (get_class_vars(get_class($this)) as $name => $default) {
356 8
                    if ($name === 'primitive')
357 8
                        continue;
358
                    
359 8
                    if (array_key_exists($name, $defaults))
360 8
                        $this->$name = $defaults[$name];
361 8
                    elseif (array_key_exists($name, self::P_COMMON_PROPS))
362 8
                        $this->$name = self::P_COMMON_PROPS[$name];
363
                    else
364 8
                        unset($this->$name);
365
                }
366
            } else {
367 8
                throw new InvalidComponentArgumentException($primitive, 'Geometry::primitive');
0 ignored issues
show
Bug introduced by
It seems like $primitive defined by parameter $primitive on line 348 can also be of type null; however, AframeVR\Core\Exceptions...xception::__construct() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
368
            }
369
        } catch (InvalidComponentArgumentException $e) {
370
            die($e->getMessage());
371
        }
372 8
    }
373
374
    /**
375
     * Set Buffer
376
     *
377
     * Transform geometry into a BufferGeometry to reduce memory usage at the cost of being harder to manipulate.
378
     *
379
     * @param string $buffer            
380
     */
381
    public function buffer($buffer = 'true')
382
    {
383
        $this->buffer = $buffer;
0 ignored issues
show
Bug introduced by
The property buffer does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
384
    }
385
386
    /**
387
     * skipCache
388
     *
389
     * Disable retrieving the shared geometry object from the cache.
390
     *
391
     * @param string $skipCache            
392
     */
393
    public function skipCache($skipCache = 'false')
394
    {
395
        $this->skipCache = $skipCache;
0 ignored issues
show
Bug introduced by
The property skipCache does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
396
    }
397
398 4
    public function width($width)
399
    {
400 4
        $this->width = $width;
401 4
    }
402
403 8
    public function height($height)
404
    {
405 8
        $this->height = $height;
406 8
    }
407
408 4
    public function depth($depth)
409
    {
410 4
        $this->depth = $depth;
411 4
    }
412
413 4
    public function radius($radius)
414
    {
415 4
        $this->radius = $radius;
416 4
    }
417
418
    public function radiusTubular($radiusTubular)
419
    {
420
        $this->radiusTubular = $radiusTubular;
421
    }
422
423
    public function radiusBottom($radiusBottom)
424
    {
425
        $this->radiusBottom = $radiusBottom;
426
    }
427
428
    public function radiusTop($radiusTop)
429
    {
430
        $this->radiusTop = $radiusTop;
431
    }
432
433
    public function segments($segments)
434
    {
435
        $this->segments = $segments;
436
    }
437
438 4
    public function thetaStart($thetaStart)
439
    {
440 4
        $this->thetaStart = $thetaStart;
441 4
    }
442
443 4
    public function thetaLength($thetaLength)
444
    {
445 4
        $this->thetaLength = $thetaLength;
446 4
    }
447
448 4
    public function openEnded($openEnded)
449
    {
450 4
        $this->openEnded = $openEnded;
451 4
    }
452
453
    public function segmentsRadial($segmentsRadial)
454
    {
455
        $this->segmentsRadial = $segmentsRadial;
456
    }
457
458 4
    public function segmentsHeight($segmentsHeight)
459
    {
460 4
        $this->segmentsHeight = $segmentsHeight;
461 4
    }
462
463
    public function segmentsWidth($segmentsWidth)
464
    {
465
        $this->segmentsWidth = $segmentsWidth;
466
    }
467
468
    public function segmentsTheta($segmentsTheta)
469
    {
470
        $this->segmentsTheta = $segmentsTheta;
471
    }
472
473
    public function segmentsPhi($segmentsPhi)
474
    {
475
        $this->segmentsPhi = $segmentsPhi;
476
    }
477
478
    public function segmentsTubular($segmentsTubular)
479
    {
480
        $this->segmentsTubular = $segmentsTubular;
481
    }
482
483
    public function phiStart($phiStart)
484
    {
485
        $this->phiStart = $phiStart;
486
    }
487
488
    public function phiLength($phiLength)
489
    {
490
        $this->phiLength = $phiLength;
491
    }
492
493
    public function radiusInner($radiusInner)
494
    {
495
        $this->radiusInner = $radiusInner;
496
    }
497
498
    public function radiusOuter($radiusOuter)
499
    {
500
        $this->radiusOuter = $radiusOuter;
501
    }
502
503
    public function arc($arc)
504
    {
505
        $this->arc = $arc;
506
    }
507
508
    public function p($p)
509
    {
510
        $this->p = $p;
511
    }
512
513
    public function q($q)
514
    {
515
        $this->q = $q;
516
    }
517
518 3
    public function translate($translate)
519
    {
520 3
        $this->translate = $translate;
521 3
    }
522
523
    /**
524
     * Magic Call
525
     *
526
     * @param string $method            
527
     * @param array $args            
528
     * @throws InvalidComponentMethodException
529
     */
530
    public function __call($method, $args)
531
    {
532
        if ($method === 'primitive') {
533
            return call_user_func_array(array(
534
                $this,
535
                $method
536
            ), $args);
537
        }
538
        try {
539
            if (method_exists($this, $method) && $this->isPrimitiveMethod($method)) {
0 ignored issues
show
Documentation introduced by
$method is of type string, but the function expects a object<AframeVR\Components\unknown>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
540
                return call_user_func_array(array(
541
                    $this,
542
                    $method
543
                ), $args);
544
            } else {
545
                throw new InvalidComponentMethodException($method, 'Geometry::primitive ' . $this->primitive);
546
            }
547
        } catch (InvalidComponentMethodException $e) {
548
            die($e->getMessage());
549
        }
550
    }
551
552
    /**
553
     * Is called method allowed for current primitive
554
     *
555
     * @param unknown $method            
556
     */
557
    protected function isPrimitiveMethod($method)
558
    {
559
        switch ($this->primitive) {
560
            case 'box':
561
                return in_array($method, self::P_BOX) ? self::P_BOX : false;
562
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
563
            case 'circle':
564
                return in_array($method, self::P_CIRCLE) ? self::P_CIRCLE : false;
565
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
566
            case 'cone':
567
                return in_array($method, self::P_CONE) ? self::P_CONE : false;
568
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
569
            case 'cylinder':
570
                return in_array($method, self::P_CYLINDER) ? self::P_CYLINDER : false;
571
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
572
            case 'plane':
573
                return in_array($method, self::P_PLANE) ? self::P_PLANE : false;
574
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
575
            case 'ring':
576
                return in_array($method, self::P_RING) ? self::P_RING : false;
577
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
578
            case 'sphere':
579
                return in_array($method, self::P_SPHERE) ? self::P_SPHERE : false;
580
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
581
            case 'torus':
582
                return in_array($method, self::P_TORUS) ? self::P_TORUS : false;
583
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
584
            case 'torusKnot':
585
                return in_array($method, self::P_TORUS_KNOT) ? self::P_TORUS_KNOT : false;
586
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
587
            default:
588
                return false;
589
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
590
        }
591
    }
592
593
    /**
594
     * Get defaults for current primitve type
595
     *
596
     * @return array;
0 ignored issues
show
Documentation introduced by
The doc-type array; could not be parsed: Expected "|" or "end of type", but got ";" at position 5. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
597
     */
598 8
    protected function primitiveDefaults(): array
599
    {
600 8
        switch ($this->primitive) {
601 8
            case 'box':
602 4
                return self::P_BOX;
603
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
604 4
            case 'circle':
605
                return self::P_CIRCLE;
606
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
607 4
            case 'cone':
608
                return self::P_CONE;
609
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
610 4
            case 'cylinder':
611 4
                return self::P_CYLINDER;
612
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
613
            case 'plane':
614
                return self::P_PLANE;
615
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
616
            case 'ring':
617
                return self::P_RING;
618
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
619
            case 'sphere':
620
                return self::P_SPHERE;
621
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
622
            case 'torus':
623
                return self::P_TORUS;
624
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
625
            case 'torusKnot':
626
                return self::P_TORUS_KNOT;
627
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
628
            default:
629
                return array();
630
                break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
631
        }
632
    }
633
}
634