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

MeshAttributes   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 107
Duplicated Lines 0 %

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 0
loc 107
ccs 32
cts 32
cp 1
rs 10
c 1
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A color() 0 7 1
A metalness() 0 7 1
A roughness() 0 7 1
A src() 0 7 1
A translate() 0 5 1
A shader() 0 5 1
A opacity() 0 5 1
A transparent() 0 5 1
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 21, 2016 - 2:56:57 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         MeshAttributes.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\Helpers;
25
26
use \AframeVR\Interfaces\EntityInterface;
27
28
/**
29
 * Many of the primitives are entities that compose a geometric mesh, meaning they
30
 * primarily prescribe the geometry and material components.
31
 * Most of the mesh
32
 * primitives share common attributes, especially for mapping to the material component.
33
 * These common attributes won’t be described in individual
34
 * documentation pages for each primitive so they will be listed here
35
 */
36
trait MeshAttributes
37
{
38
39
    /**
40
     * material.color
41
     *
42
     * @param string $color            
43
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
44
     */
45 3
    public function color(string $color = 'gray'): EntityInterface
46
    {
47 3
        $this->component('Material')
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
48 3
            ->shader()
49 3
            ->color($color);
50 3
        return $this;
51
    }
52
53
    /**
54
     * material.metalness
55
     *
56
     * @param string $metalness            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $metalness not be integer?

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...
57
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
58
     */
59 3
    public function metalness($metalness = 0): EntityInterface
60
    {
61 3
        $this->component('Material')
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
62 3
            ->shader()
63 3
            ->metalness($metalness);
64 3
        return $this;
65
    }
66
67
    /**
68
     * material.roughness
69
     *
70
     * @param string $roughness            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $roughness not be double?

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...
71
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
72
     */
73 3
    public function roughness($roughness = 0.5): EntityInterface
74
    {
75 3
        $this->component('Material')
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
76 3
            ->shader()
77 3
            ->roughness($roughness);
78 3
        return $this;
79
    }
80
81
    /**
82
     * material.src
83
     *
84
     * @param string $src            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $src not be null|string?

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...
85
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
86
     */
87 3
    public function src(string $src = null): EntityInterface
88
    {
89 3
        $this->component('Material')
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
90 3
            ->shader()
91 3
            ->src($src);
92 3
        return $this;
93
    }
94
95
    /**
96
     * geometry.translate
97
     *
98
     * @param string $translate            
99
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
100
     */
101 3
    public function translate($translate = '0 0 0'): EntityInterface
102
    {
103 3
        $this->component('Geometry')->translate($translate);
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
104 3
        return $this;
105
    }
106
107
    /**
108
     * material.shader
109
     *
110
     * @param string $shader            
111
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
112
     */
113 3
    public function shader($shader = 'standard'): EntityInterface
114
    {
115 3
        $this->component('Material')->shader($shader);
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
116 3
        return $this;
117
    }
118
119
    /**
120
     * material.opacity
121
     *
122
     * @param string $opacity            
0 ignored issues
show
Documentation introduced by
Should the type for parameter $opacity not be double?

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...
123
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
124
     */
125 3
    public function opacity(float $opacity = 1.0): EntityInterface
126
    {
127 3
        $this->component('Material')->opacity($opacity);
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
128 3
        return $this;
129
    }
130
131
    /**
132
     * material.transparent
133
     *
134
     * @param string $transparent            
135
     * @return \AframeVR\Core\Helpers\MeshAttributes
0 ignored issues
show
Comprehensibility Bug introduced by
The return type MeshAttributes is a trait, and thus cannot be used for type-hinting in PHP. Maybe consider adding an interface and use that for type-hinting?

In PHP traits cannot be used for type-hinting as they do not define a well-defined structure. This is because any class that uses a trait can rename that trait’s methods.

If you would like to return an object that has a guaranteed set of methods, you could create a companion interface that lists these methods explicitly.

Loading history...
136
     */
137 3
    public function transparent(string $transparent = 'false'): EntityInterface
138
    {
139 3
        $this->component('Material')->transparent($transparent);
0 ignored issues
show
Bug introduced by
It seems like component() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
140 3
        return $this;
141
    }
142
}
143