Completed
Pull Request — master (#22)
by Daryl
01:39
created

Map_Model   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 156
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
c 2
b 0
f 0
lcom 0
cbo 1
dl 156
loc 156
ccs 0
cts 11
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __call() 21 21 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Clubdeuce\WPLib\Components\GoogleMaps;
4
5
6
/**
7
 * Class Map_Model
8
 * @package Clubdeuce\WPLib\Components\GoogleMaps
9
 */
10 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...
11
12
	/**
13
	 * @var Map
14
	 */
15
	protected $_map;
16
17
	/**
18
	 * @param  string $method_name
19
	 * @return mixed
20
	 */
21
	function __call( $method_name, $args ) {
22
		$value = null;
23
24
		do {
25
26
			if ( property_exists( $this, "_{$method_name}" ) ) {
27
				$property = "_{$method_name}";
28
				$value = $this->{$property};
29
				break;
30
			}
31
32
			if ( ! isset( $this->_map ) ) {
33
				break;
34
			}
35
36
			$value = call_user_func_array( array( $this->_map, $method_name ), $args );
37
38
		} while ( false );
39
40
		return $value;
41
	}
42
43
//    /**
44
//     * @var array
45
//     */
46
//    protected $_center;
47
//
48
//    /**
49
//     * The Map element height (default: 400px).
50
//     * @var string
51
//     */
52
//    protected $_height = '400px';
53
//
54
//    /**
55
//     * The string to use for the map HTML element id property
56
//     *
57
//     * @var string
58
//     */
59
//    protected $_html_id;
60
//
61
//    /**
62
//     * @var Marker[]
63
//     */
64
//    protected $_markers = array();
65
//
66
//    /**
67
//     * The Map element width (default: 100%).
68
//     * @var string
69
//     */
70
//    protected $_width = '100%';
71
//
72
//    /**
73
//     * @var int
74
//     */
75
//    protected $_zoom = 5;
76
//
77
//    /**
78
//     * @param Marker $marker
79
//     */
80
//    function add_marker( $marker ) {
81
//
82
//        $this->_markers[] = $marker;
83
//
84
//    }
85
//
86
//    /**
87
//     * @param Marker[] $markers
88
//     */
89
//    function add_markers( $markers ) {
90
//
91
//        $this->_markers = array_merge( $this->_markers, $markers );
92
//
93
//    }
94
//
95
//    /**
96
//     * @return array
97
//     */
98
//    function center() {
99
//
100
//        return $this->_center;
101
//
102
//    }
103
//
104
//    /**
105
//     * @return string
106
//     */
107
//    function height() {
108
//
109
//        return $this->_height;
110
//
111
//    }
112
//
113
//    /**
114
//     * @return string
115
//     */
116
//    function html_id() {
117
//
118
//        if ( ! isset( $this->_html_id ) ) {
119
//            $this->_html_id = sprintf( 'map-%1$s', md5( serialize( array( $this->center(), $this->markers() ) ) ) );
120
//        }
121
//
122
//        return $this->_html_id;
123
//
124
//    }
125
//
126
//    /**
127
//     * @return Marker[]
128
//     */
129
//    function markers() {
130
//
131
//        return $this->_markers;
132
//
133
//    }
134
//
135
//    /**
136
//     * @return string
137
//     */
138
//    function width() {
139
//
140
//        return $this->_width;
141
//
142
//    }
143
//
144
//    /**
145
//     * @return int
146
//     */
147
//    function zoom() {
148
//
149
//        return $this->_zoom;
150
//
151
//    }
152
//
153
//	/**
154
//	 * @return array
155
//	 */
156
//	function make_args() {
157
//
158
//		return array(
159
//			'center' => $this->center(),
160
//			'zoom'   => (int)$this->zoom()
161
//		);
162
//
163
//	}
164
165
}
166