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

Marker_Label_Model   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 69.23%

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 0
cbo 1
dl 45
loc 45
ccs 9
cts 13
cp 0.6923
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A has_label() 5 5 1
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
 * Class Marker_Label_Model
7
 * @package Clubdeuce\WPLib\Components\GoogleMaps
8
 *
9
 * @mixin Marker_Label;
10
 */
11 View Code Duplication
class Marker_Label_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...
12
13
	/**
14
	 * @var \Clubdeuce\WPGoogleMaps\Marker_Label
15
	 */
16
	protected $_label;
17
18
	/**
19
	 * @return bool
20
	 */
21 1
	function has_label() {
22
23 1
		return $this->_has( '_label' );
24
25
	}
26
27
	/**
28
	 * @param  string $method_name
29
	 * @param  array  $args
30
	 *
31
	 * @return mixed
32
	 */
33 1
	function __call( $method_name, $args = array() ) {
34 1
		$value = null;
35
36
		do {
37
38 1
			if ( property_exists( $this, "_{$method_name}" ) ) {
39
				$property = "_{$method_name}";
40
				$value = $this->{$property};
41
				break;
42
			}
43
44 1
			if ( ! isset( $this->_label ) ) {
45
				break;
46
			}
47
48 1
			$value = call_user_func_array( array( $this->_label, $method_name ), $args );
49
50 1
		} while ( false );
51
52 1
		return $value;
53
	}
54
55
}
56