Completed
Push — master ( ed64c2...186a7a )
by
unknown
8s
created

Basis   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 30
rs 10
wmc 8
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B import() 0 20 8
1
<?php
2
/**
3
 * Includes Basic Class methods that are common used in other classes.
4
 *
5
 * @package Classy
6
 */
7
8
namespace Classy;
9
10
/**
11
 * Class Basis.
12
 */
13
class Basis {
14
15
	/**
16
	 * Imports data params into the class instance.
17
	 *
18
	 * @param  object|array $data
19
	 *
20
	 * @return void
21
	 */
22
	protected function import( $data ) {
23
		if ( is_object( $data ) ) {
24
			$data = get_object_vars( $data );
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $data. This often makes code more readable.
Loading history...
25
		}
26
27
		if ( is_array( $data ) ) {
28
			// In case if we import WP_User object.
29
			if ( isset( $data['data'] ) ) {
30
				$data = $data['data'];
0 ignored issues
show
Coding Style introduced by
Consider using a different name than the parameter $data. This often makes code more readable.
Loading history...
31
			}
32
33
			foreach ( $data as $key => $value ) {
34
				if ( ! empty( $key ) ) {
35
					$this->$key = $value;
36
				} else if ( ! empty( $key ) && ! method_exists( $this, $key ) ) {
37
					$this->$key = $value;
38
				}
39
			}
40
		}
41
	}
42
}
43