Completed
Branch master (fb685e)
by Marko
02:00
created

CylinderMethods   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 116
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 0
cbo 0
dl 116
loc 116
ccs 21
cts 21
cp 1
rs 10
c 1
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A height() 4 4 1
A openEnded() 5 5 2
A radius() 4 4 1
A segmentsHeight() 4 4 1
A thetaLength() 4 4 1
A thetaStart() 4 4 1
A segmentsRadial() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 27, 2016 - 4:29:53 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         CylinderMethods.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\Core\Components\Geometry\Methods;
25
26 View Code Duplication
class CylinderMethods
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
27
{
28
29
    /**
30
     * The cylinder primitive can define cylinders in the traditional sense like a Coca-Cola™ can,
31
     * but it can also define shapes such as tubes and curved surfaces.
32
     * We’ll go over some of these cylinder recipes below.
33
     * 1. Traditional cylinders can be defined by using only a height and a radius:
34
     * 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.
35
     * A double-sided material will be needed to render properly:
36
     * 3. Curved surfaces can be defined by specifying the angle via thetaLength such that the cylinder doesn’t curve all the way around,
37
     * making the cylinder open-ended, and then making the material double-sided.
38
     * 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:
39
     */
40
    const DEFAULTS = array(
41
        /* Radius of the cylinder. */
42
        'height' => 3,
43
        /* Height of the cylinder. */
44
        'radius' => 2,
45
        /* Number of segmented faces around the circumference of the cylinder. */
46
        'segmentsRadial' => 36,
47
        /* Number of rows of faces along the height of the cylinder. */
48
        'segmentsHeight' => 18,
49
        /* Whether the ends of the cylinder are open (true) or capped ('false'). */
50
        'openEnded' => 'false',
51
        /* Starting angle in degrees. */
52
        'thetaStart' => 0,
53
        /* Central angle in degrees. */
54
        'thetaLength' => 360
55
    );
56
57
    /**
58
     * Height of the cylinder.
59
     *
60
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
61
     * @param float|int $height            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $height a bit more specific; maybe use double.
Loading history...
62
     * @return void
63
     */
64 6
    public function height(array &$dom_attributes, float $height)
65
    {
66 6
        $dom_attributes['height'] = $height;
67 6
    }
68
69
    /**
70
     * Whether the ends of the cylinder are open (true) or capped (false).
71
     *
72
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
73
     * @param bool|false $openEnded            
74
     * @return void
75
     */
76 6
    public function openEnded(array &$dom_attributes, bool $openEnded = false)
77
    {
78 6
        $dom_attributes['openEnded'] = $openEnded ? 'true' : 'false';
79
        ;
80 6
    }
81
82
    /**
83
     * Radius of the cylinder.
84
     *
85
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
86
     * @param float|int $radius            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $radius a bit more specific; maybe use double.
Loading history...
87
     * @return void
88
     */
89 6
    public function radius(array &$dom_attributes, float $radius)
90
    {
91 6
        $dom_attributes['radius'] = $radius;
92 6
    }
93
94
    /**
95
     * Number of rows of faces along the height of the cylinder.
96
     *
97
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
98
     * @param int $segmentsHeight            
99
     * @return void
100
     */
101 6
    public function segmentsHeight(array &$dom_attributes, int $segmentsHeight)
102
    {
103 6
        $dom_attributes['segmentsHeight'] = $segmentsHeight;
104 6
    }
105
106
    /**
107
     * Central angle in degrees.
108
     *
109
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
110
     * @param float|int $thetaLength            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $thetaLength a bit more specific; maybe use double.
Loading history...
111
     * @return void
112
     */
113 6
    public function thetaLength(array &$dom_attributes, float $thetaLength)
114
    {
115 6
        $dom_attributes['thetaLength'] = $thetaLength;
116 6
    }
117
118
    /**
119
     * Starting angle in degrees.
120
     *
121
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
122
     * @param float|int $thetaStart            
0 ignored issues
show
Documentation introduced by
Consider making the type for parameter $thetaStart a bit more specific; maybe use double.
Loading history...
123
     * @return void
124
     */
125 6
    public function thetaStart(array &$dom_attributes, float $thetaStart)
126
    {
127 6
        $dom_attributes['thetaStart'] = $thetaStart;
128 6
    }
129
130
    /**
131
     * Number of segmented faces around the circumference of the cylinder.
132
     *
133
     * @param &array $dom_attributes            
0 ignored issues
show
Documentation introduced by
The doc-type &array could not be parsed: Unknown type name "&array" at position 0. (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...
134
     * @param int $segmentsRadial            
135
     * @return void
136
     */
137 1
    public function segmentsRadial(array &$dom_attributes, int $segmentsRadial)
138
    {
139 1
        $dom_attributes['segmentsRadial'] = $segmentsRadial;
140 1
    }
141
}
142