Completed
Pull Request — master (#22)
by Daryl
07:43
created

Info_Window_Model::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.6666
cc 1
eloc 4
nc 1
nop 1
crap 1
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
 */
15
class Info_Window_Model extends Model_Base {
16
17
	/**
18
	 * @var \Clubdeuce\WPGoogleMaps\Info_Window
19
	 */
20
	protected $_info_window;
21
22
	/**
23
	 * Info_Window constructor.
24
	 *
25
	 * @param array $args
26
	 */
27 1
	function __construct( $args = array() ) {
28
29 1
		$args = wp_parse_args( $args, array(
30 1
			'info_window' => new \Clubdeuce\WPGoogleMaps\Info_Window( $args ),
31
		) );
32
33 1
		parent::__construct( $args );
34
35 1
	}
36
37
	/**
38
	 * @return bool
39
	 */
40 1
	function has_info_window() {
41
42 1
		return $this->_has( '_info_window' );
43
44
	}
45
46
	/**
47
	 * @param string $method_name
48
	 * @param array $args
49
	 *
50
	 * @return mixed|null
51
	 */
52 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...
53
54 3
		$value = null;
0 ignored issues
show
Unused Code introduced by
$value is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
55
56
		do {
57 3
			$value = parent::__call( $method_name, $args );
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $value is correct as parent::__call($method_name, $args) (which targets Clubdeuce\WPLib\Componen...ps\Model_Base::__call()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
58
59 3
			if ( $value ) {
60 2
				break;
61
			}
62
63 2
			if ( $this->has_info_window() ) {
64 1
				$value = call_user_func_array( array( $this->info_window(), $method_name ), $args );
65 1
				break;
66
			}
67 1
		} while ( false );
68
69 3
		return $value;
70
71
	}
72
73
}
74