Completed
Pull Request — master (#22)
by Daryl
02:28
created

Info_Window_Model::__call()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 18
Code Lines 10

Duplication

Lines 18
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 18
loc 18
ccs 9
cts 9
cp 1
rs 9.2
cc 4
eloc 10
nc 3
nop 2
crap 4
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
5
/**
6
 * Class Info_Window_Model
7
 * @package Clubdeuce\WPLib\Components\GoogleMaps
8
 *
9
 * @method \Clubdeuce\WPGoogleMaps\Info_Window info_window()
10
 * @method string content()
11
 * @method int    pixel_offset()
12
 * @method array  position()
13
 * @method int    max_width()
14
 * @method void   set_content()
15
 * @method void   det_pixel_offset()
16
 * @method void   set_position()
17
 * @method void   set_max_width()
18
 */
19
class Info_Window_Model extends Model_Base {
20
21
	/**
22
	 * @var \Clubdeuce\WPGoogleMaps\Info_Window
23
	 */
24
	protected $_info_window;
25
26
	/**
27
	 * Info_Window constructor.
28
	 *
29
	 * @param array $args
30
	 */
31 1
	function __construct( $args = array() ) {
32
33 1
		$args = wp_parse_args( $args, array(
34 1
			'info_window' => new \Clubdeuce\WPGoogleMaps\Info_Window( $args ),
35
		) );
36
37 1
		parent::__construct( $args );
38
39 1
	}
40
41
	/**
42
	 * @return bool
43
	 */
44 1
	function has_info_window() {
45
46 1
		return $this->_has( '_info_window' );
47
48
	}
49
50
	/**
51
	 * @param string $method_name
52
	 * @param array $args
53
	 *
54
	 * @return mixed|null
55
	 */
56 3 View Code Duplication
	function __call( $method_name, $args ) {
0 ignored issues
show
Duplication introduced by
This method 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...
57
58
		do {
59 3
			$value = parent::__call( $method_name, $args );
60
61 3
			if ( $value ) {
62 2
				break;
63
			}
64
65 2
			if ( $this->has_info_window() ) {
66 1
				$value = call_user_func_array( array( $this->info_window(), $method_name ), $args );
67 1
				break;
68
			}
69 1
		} while ( false );
70
71 3
		return $value;
72
73
	}
74
75
}
76