Passed
Branch master (8cb5b2)
by Christopher
04:33 queued 12s
created

Geo   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 78
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 8

4 Methods

Rating   Name   Duplication   Size   Complexity  
A geoShape() 0 3 1
A geoPolygon() 0 14 3
A geoDistance() 0 8 1
A geoBoundingBox() 0 14 3
1
<?php
0 ignored issues
show
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
2
namespace Triadev\Leopard\Business\Dsl\Query;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use ONGR\ElasticsearchDSL\Query\Geo\GeoBoundingBoxQuery;
5
use ONGR\ElasticsearchDSL\Query\Geo\GeoDistanceQuery;
6
use ONGR\ElasticsearchDSL\Query\Geo\GeoPolygonQuery;
7
use ONGR\ElasticsearchDSL\Query\Geo\GeoShapeQuery;
8
use Triadev\Leopard\Model\Location;
9
use Triadev\Leopard\Business\Dsl\AbstractQuery;
10
11
class Geo extends AbstractQuery
0 ignored issues
show
Coding Style Documentation introduced by
Missing class doc comment
Loading history...
12
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class Geo
Loading history...
13
    /**
14
     * Geo bounding box
15
     *
16
     * @param string $field
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
17
     * @param Location[] $locations
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
18
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 6 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
19
     * @return Geo
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
20
     */
21 1
    public function geoBoundingBox(string $field, array $locations, array $params = []): Geo
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines before function; 0 found
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$params"; expected 0 but found 1
Loading history...
22
    {
23 1
        $l = [];
24
        
25 1
        foreach ($locations as $location) {
26 1
            if ($location instanceof Location) {
27 1
                $l[] = [
28 1
                    'lat' => $location->getLatitude(),
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 24 spaces, but found 20.
Loading history...
29 1
                    'lon' => $location->getLongitude()
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 24 spaces, but found 20.
Loading history...
30
                ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 23 space(s), but found 16.
Loading history...
31
            }
32
        }
33
        
34 1
        return $this->append(new GeoBoundingBoxQuery($field, $l, $params));
35
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end geoBoundingBox()
Loading history...
36
    
37
    /**
38
     * Geo distance
39
     *
40
     * @param string $field
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
41
     * @param string $distance
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
42
     * @param Location $location
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
43
     * @return Geo
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
44
     */
45 2
    public function geoDistance(string $field, string $distance, Location $location): Geo
46
    {
47 2
        return $this->append(new GeoDistanceQuery(
1 ignored issue
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
48 2
            $field,
49 2
            $distance,
50
            [
51 2
                'lat' => $location->getLatitude(),
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 13 spaces, but found 16.
Loading history...
52 2
                'lon' => $location->getLongitude()
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 13 spaces, but found 16.
Loading history...
53
            ]
54
        ));
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
55
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end geoDistance()
Loading history...
56
    
57
    /**
58
     * Geo polygon
59
     *
60
     * @param string $field
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Expected 5 spaces after parameter type; 1 found
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
61
     * @param Location[] $points
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
62
     * @return Geo
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
63
     */
64 1
    public function geoPolygon(string $field, array $points): Geo
65
    {
66 1
        $p = [];
67
        
68 1
        foreach ($points as $point) {
69 1
            if ($point instanceof Location) {
70 1
                $p[] = [
71 1
                    'lat' => $point->getLatitude(),
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 24 spaces, but found 20.
Loading history...
72 1
                    'lon' => $point->getLongitude()
0 ignored issues
show
Coding Style introduced by
This array key does not seem to be aligned correctly; expected 24 spaces, but found 20.
Loading history...
73
                ];
0 ignored issues
show
Coding Style introduced by
The closing parenthesis does not seem to be aligned correctly; expected 23 space(s), but found 16.
Loading history...
74
            }
75
        }
76
        
77 1
        return $this->append(new GeoPolygonQuery($field, $p));
78
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 1 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end geoPolygon()
Loading history...
79
    
80
    /**
81
     * Geo shape
82
     *
83
     * @param array $params
0 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value indented incorrectly; expected 2 spaces but found 1
Loading history...
84
     * @return Geo
0 ignored issues
show
Coding Style introduced by
Tag cannot be grouped with parameter tags in a doc comment
Loading history...
85
     */
86 1
    public function geoShape(array $params = []): Geo
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$params" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$params"; expected 0 but found 1
Loading history...
87
    {
88 1
        return $this->append(new GeoShapeQuery($params));
89
    }
0 ignored issues
show
Coding Style introduced by
Expected 2 blank lines after function; 0 found
Loading history...
Coding Style introduced by
Expected 1 blank line before closing function brace; 0 found
Loading history...
Coding Style introduced by
Expected //end geoShape()
Loading history...
90
}
0 ignored issues
show
Coding Style introduced by
Expected //end class
Loading history...
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
91