PolygonParser::handlePolygonParams()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 0
cts 11
cp 0
rs 9.8333
c 0
b 0
f 0
cc 4
nc 8
nop 2
crap 20
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