Completed
Push — master ( ab4944...534e9c )
by Andrew
02:30
created

ClassyBasis::import()   C

Complexity

Conditions 7
Paths 10

Size

Total Lines 26
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 7
eloc 9
c 1
b 0
f 1
nc 10
nop 1
dl 0
loc 26
rs 6.7272
1
<?php 
2
3
/**
4
 * Includes Basic Class methods that are common used in other classes
5
 */
6
7
class ClassyBasis {
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
8
9
    /**
10
     * Imports data params into the class instance
11
     * 
12
     * @param  object/array $data
0 ignored issues
show
Documentation introduced by
The doc-type object/array could not be parsed: Unknown type name "object/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...
13
     * @return void
14
     */
15
	protected function import($data) {
16
17
        if ( is_object( $data ) ) {
18
        
19
            $data = get_object_vars( $data );
20
        
21
        }
22
23
        if ( is_array( $data ) ) {
24
            
25
            foreach ( $data as $key => $value ) {
26
            
27
                if ( !empty( $key ) ) {
28
            
29
                    $this->$key = $value;
30
            
31
                } else if ( !empty( $key ) && !method_exists($this, $key) ){
32
            
33
                    $this->$key = $value;
34
            
35
                }
36
            }
37
38
        }
39
40
	}
41
42
}