Completed
Push — master ( 1a7397...8cd977 )
by Daryl
04:36
created

Model_Base::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 7
cts 7
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
crap 3
1
<?php
2
3
namespace Clubdeuce\WPGoogleMaps;
4
5
/**
6
 * Class Model_Base
7
 * @package Clubdeuce\WPGoogleMaps
8
 */
9
class Model_Base {
10
11
	/**
12
	 * @var array
13
	 */
14
	protected $_extra_args;
15
16
	/**
17
	 * Model_Base constructor.
18
	 *
19
	 * @param array $args
20
	 */
21 9
	public function __construct( $args = array() ) {
22
23 9
		$args = wp_parse_args( $args );
24
25 9
		foreach ( $args as $key => $arg ) {
26
27 8
			if ( property_exists( $this, "_{$key}" ) ) {
28 8
				$property = "_{$key}";
29 8
				$this->{$property} = $arg;
30
			}
31
32
		}
33
34 9
	}
35
36
	/**
37
	 * @param string $method_name
38
	 * @param array  $args
39
	 *
40
	 * @return mixed|null
41
	 */
42 6
	public function __call( $method_name, $args ) {
43
44 6
		$value = null;
45
46 6
		if ( property_exists( $this, "_{$method_name}" ) ) {
47 6
			$property = "_{$method_name}";
48 6
			$value    = $this->{$property};
49
		}
50
51 6
		return $value;
52
53
	}
54
55
}
56