SpatialPolygonFilter   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
eloc 14
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 1
A toArray() 0 9 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Level23\Druid\Filters;
5
6
/**
7
 * Class SpatialPolygonFilter
8
 *
9
 * @package Level23\Druid\Filters
10
 */
11
class SpatialPolygonFilter implements FilterInterface
12
{
13
    protected string $dimension;
14
15
    /**
16
     * @var float[]
17
     */
18
    protected array $abscissa;
19
20
    /**
21
     * @var float[]
22
     */
23
    protected array $ordinate;
24
25
    /**
26
     * SpatialPolygonFilter constructor.
27
     *
28
     * @param string  $dimension The dimension to filter on
29
     * @param float[] $abscissa  Horizontal coordinate for corners of the polygon
30
     * @param float[] $ordinate  Vertical coordinate for corners of the polygon
31
     */
32 1
    public function __construct(
33
        string $dimension,
34
        array $abscissa,
35
        array $ordinate
36
    ) {
37 1
        $this->dimension = $dimension;
38 1
        $this->abscissa  = $abscissa;
39 1
        $this->ordinate  = $ordinate;
40
    }
41
42
    /**
43
     * Return the filter as it can be used in the druid query.
44
     *
45
     * @return array<string,string|array<string,string|float[]>>
46
     */
47 1
    public function toArray(): array
48
    {
49 1
        return [
50 1
            'type'      => 'spatial',
51 1
            'dimension' => $this->dimension,
52 1
            'bound'     => [
53 1
                'type'     => 'polygon',
54 1
                'abscissa' => $this->abscissa,
55 1
                'ordinate' => $this->ordinate,
56 1
            ],
57 1
        ];
58
    }
59
}