clubdeuce /
wplib-olm-google-maps
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Clubdeuce\WPLib\Components\GoogleMaps; |
||
| 4 | use Clubdeuce\WPGoogleMaps\Marker_Label; |
||
|
0 ignored issues
–
show
|
|||
| 5 | |||
| 6 | /** |
||
| 7 | * Class Marker_Label_Model |
||
| 8 | * @package Clubdeuce\WPLib\Components\GoogleMaps |
||
| 9 | * |
||
| 10 | * @mixin Marker_Label; |
||
| 11 | */ |
||
| 12 | View Code Duplication | class Marker_Label_Model extends Model_Base { |
|
|
0 ignored issues
–
show
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...
|
|||
| 13 | |||
| 14 | /** |
||
| 15 | * @var \Clubdeuce\WPGoogleMaps\Marker_Label |
||
| 16 | */ |
||
| 17 | protected $_label; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return bool |
||
| 21 | */ |
||
| 22 | 1 | function has_label() { |
|
| 23 | |||
| 24 | 1 | return $this->_has( '_label' ); |
|
| 25 | |||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param string $method_name |
||
| 30 | * @param array $args |
||
| 31 | * |
||
| 32 | * @return mixed |
||
| 33 | */ |
||
| 34 | 3 | function __call( $method_name, $args = array() ) { |
|
| 35 | 3 | $value = null; |
|
| 36 | |||
| 37 | do { |
||
| 38 | |||
| 39 | 3 | if ( property_exists( $this, "_{$method_name}" ) ) { |
|
| 40 | $property = "_{$method_name}"; |
||
| 41 | $value = $this->{$property}; |
||
| 42 | break; |
||
| 43 | } |
||
| 44 | |||
| 45 | 3 | if ( ! isset( $this->_label ) ) { |
|
| 46 | break; |
||
| 47 | } |
||
| 48 | |||
| 49 | 3 | $value = call_user_func_array( array( $this->_label, $method_name ), $args ); |
|
| 50 | |||
| 51 | 3 | } while ( false ); |
|
| 52 | |||
| 53 | 3 | return $value; |
|
| 54 | } |
||
| 55 | |||
| 56 | } |
||
| 57 |
Let’s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let’s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.phpHowever, as
OtherDir/Foo.phpdoes not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: