Completed
Push — master ( ad9f08...10f8db )
by Daryl
01:45
created

Map_Model::__call()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 21
Code Lines 12

Duplication

Lines 21
Ratio 100 %

Code Coverage

Tests 10
CRAP Score 4.0119

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 21
loc 21
ccs 10
cts 11
cp 0.9091
rs 9.0534
cc 4
eloc 12
nc 3
nop 2
crap 4.0119
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
use Clubdeuce\WPGoogleMaps\Map as WPMap;
5
6
7
/**
8
 * Class Map_Model
9
 * @package Clubdeuce\WPLib\Components\GoogleMaps
10
 *
11
 * @method map()
12
 *
13
 * @mixin  WPMap
14
 */
15 View Code Duplication
class Map_Model extends Model_Base {
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
16
17
	/**
18
	 * @var WPMap
19
	 */
20
	protected $_map;
21
22
	/**
23
	 * @return bool
24
	 */
25 2
	function has_map() {
26
27 2
		return $this->_has('_map' );
28
29
	}
30
31
	/**
32
	 * @param  string $method_name
33
	 * @param  array  $args
34
	 *
35
	 * @return mixed
36
	 */
37 2
	function __call( $method_name, $args = array() ) {
38 2
		$value = null;
39
40
		do {
41
42 2
			if ( property_exists( $this, "_{$method_name}" ) ) {
43 1
				$property = "_{$method_name}";
44 1
				$value = $this->{$property};
45 1
				break;
46
			}
47
48 2
			if ( ! isset( $this->_map ) ) {
49
				break;
50
			}
51
52 2
			$value = call_user_func_array( array( $this->_map, $method_name ), $args );
53
54 2
		} while ( false );
55
56 2
		return $value;
57
	}
58
}
59