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

Marker_Model::info_window()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
use Clubdeuce\WPGoogleMaps\Marker as WPMarker;
5
6
/**
7
 * Class Marker_Model
8
 * @package Clubdeuce\WPLib\Components\GoogleMaps
9
 *
10
 * @method \Clubdeuce\WPGoogleMaps\Marker marker()
11
 */
12
class Marker_Model extends Model_Base {
13
14
	/**
15
	 * @var WPMarker
16
	 */
17
    protected $_marker;
18
19
	/**
20
	 * @return bool
21
	 */
22 1
	function has_marker() {
23
24 1
		return $this->_has( '_marker' );
25
26
	}
27
28
	/**
29
	 * @return Location
30
	 */
31 2
	function location() {
32
33 2
		return new Location( array( 'location' => $this->marker()->location() ) );
34
35
	}
36
37
	/**
38
	 * @return Marker_Label
39
	 */
40 1
	function label() {
41
42 1
		return new Marker_Label( array( 'label' => $this->marker()->label() ) );
43
44
	}
45
46
	/**
47
	 * @return Info_Window
48
	 */
49 1
	function info_window() {
50
51 1
		$window = new Info_Window( array( 'info_window' => $this->marker()->info_window() ) );
52 1
		$window->set_position( array( 'lat' => $this->marker()->latitude(), 'lng' => $this->marker()->longitude()));
0 ignored issues
show
Unused Code introduced by
The call to Info_Window::set_position() has too many arguments starting with array('lat' => $this->ma...>marker()->longitude()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
54 1
		return $window;
55
56
	}
57
58
	/**
59
	 * @param string $method_name
60
	 * @param array $args
61
	 *
62
	 * @return mixed|null
63
	 */
64 1 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...
65
66
		do {
67 1
			$value = parent::__call( $method_name, $args );
68
69 1
			if ( $value ) {
70 1
				break;
71
			}
72
73 1
			if ( $this->has_marker() ) {
74 1
				$value = call_user_func_array( array( $this->marker(), $method_name ), $args );
75 1
				break;
76
			}
77
		} while ( false );
78
79 1
		return $value;
80
81
	}
82
83
}
84