Completed
Push — master ( 593f0f...eb3353 )
by Marko
02:20
created

ShaderAbstract::removeDefaultDOMAttributes()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.2
cc 4
eloc 5
nc 3
nop 0
crap 4
1
<?php
2
/** @formatter:off
3
 * ******************************************************************
4
 * Created by   Marko Kungla on Jun 25, 2016 - 8:48:28 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         ShaderAbstract.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
abstract class ShaderAbstract
27
{
28
29
    /**
30
     * removeDefaultDOMAttributes
31
     *
32
     * @return void
33
     */
34 2
    public function removeDefaultDOMAttributes()
35
    {
36 2
        $defaults = $this->getShaderClassDefaultVars();
37 2
        foreach ($this as $name => $value) {
0 ignored issues
show
Bug introduced by
The expression $this of type this<AframeVR\Core\Helpers\ShaderAbstract> is not traversable.
Loading history...
38 2
            if (empty($value) || $value === $defaults[$name])
39 2
                unset($this->$name);
40
        }
41 2
    }
42
43
    /**
44
     * Get default class vars
45
     *
46
     * @return void
0 ignored issues
show
Documentation introduced by
Should the return type not be array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
47
     */
48 2
    private function getShaderClassDefaultVars()
49
    {
50 2
        return get_class_vars(get_class($this));
51
    }
52
}
53