Completed
Push — master ( 00a9a3...766140 )
by Marko
02:20
created

ShaderAbstract   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 5
c 5
b 1
f 0
lcom 0
cbo 0
dl 0
loc 27
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getShaderClassDefaultVars() 0 4 1
A removeDefaultDOMAttributes() 0 9 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
     * Get default class vars
30
     *
31
     * @return array
32
     */
33 4
    protected function getShaderClassDefaultVars()
34
    {
35 4
        return get_class_vars(get_class($this));
36
    }
37
    
38
    /**
39
     * removeDefaultDOMAttributes
40
     *
41
     * @return void
42
     */
43 4
    public function removeDefaultDOMAttributes()
44
    {
45 4
        $defaults = $this->getShaderClassDefaultVars();
46 4
        $vars = get_object_vars($this);
47 4
        foreach ($vars as $name => $value) {
48 4
            if (empty($value) || $value === $defaults[$name])
49 4
                unset($this->$name);
50
        }
51 4
    }
52
}
53