PolygonParser   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 26
ccs 0
cts 18
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A constructShapeFromLatLongValues() 0 3 1
A handleCommonParams() 0 4 1
A handlePolygonParams() 0 13 4
1
<?php
2
3
declare( strict_types = 1 );
4
5
namespace Maps\WikitextParsers;
6
7
use Maps\LegacyModel\Line;
8
use Maps\LegacyModel\Polygon;
9
10
/**
11
 * ValueParser that parses the string representation of a polygon.
12
 *
13
 * @since 3.0
14
 *
15
 * @licence GNU GPL v2+
16
 * @author Jeroen De Dauw < [email protected] >
17
 */
18
class PolygonParser extends LineParser {
19
20
	protected function constructShapeFromLatLongValues( array $locations ) {
21
		return new Polygon( $locations );
22
	}
23
24
	protected function handleCommonParams( array &$params, Line &$line ) {
25
		parent::handleCommonParams( $params, $line );
26
		$this->handlePolygonParams( $params, $line );
0 ignored issues
show
Compatibility introduced by
$line of type object<Maps\LegacyModel\Line> is not a sub-type of object<Maps\LegacyModel\Polygon>. It seems like you assume a child class of the class Maps\LegacyModel\Line to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
27
	}
28
29
	protected function handlePolygonParams( array &$params, Polygon &$polygon ) {
30
		if ( $fillColor = array_shift( $params ) ) {
31
			$polygon->setFillColor( $fillColor );
32
		}
33
34
		if ( $fillOpacity = array_shift( $params ) ) {
35
			$polygon->setFillOpacity( $fillOpacity );
36
		}
37
38
		if ( $showOnlyOnHover = array_shift( $params ) ) {
39
			$polygon->setOnlyVisibleOnHover( strtolower( trim( $showOnlyOnHover ) ) === 'on' );
40
		}
41
	}
42
43
}
44