Passed
Push — master ( fc71f1...2fa0f4 )
by Tom
03:17
created

Polygon   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 41.67%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 30
ccs 5
cts 12
cp 0.4167
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A isPointInPolygon() 0 3 1
A __toString() 0 8 2
1
<?php
2
3
namespace NoaaCapAlerts\Model\Polygon;
4
5
class Polygon
6
{
7
    private $points;
8
9
    /**
10
     * Polygon constructor.
11
     * @param array $points
12
     */
13 3
    function __construct(array $points = null)
14
    {
15 3
        if ($points === null) {
16 3
            $points = [];
17
        }
18
19 3
        $this->points = $points;
20 3
    }
21
22
    function isPointInPolygon(Point $point) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Unused Code introduced by
The parameter $point is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

22
    function isPointInPolygon(/** @scrutinizer ignore-unused */ Point $point) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Bug introduced by
The type NoaaCapAlerts\Model\Polygon\Point was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
        //@todo
24
        throw new \Exception("Method not implemented.");
25
    }
26
27
    function __toString()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
    {
29
        $pointStrings = [];
30
        foreach ($this->points as $point) {
31
            $pointStrings[] = '[' . $point->getX() . ', ' . $point->getY() . ']';
32
        }
33
34
        return "Points: " . implode(', ', $pointStrings);
35
    }
36
}