Completed
Pull Request — master (#348)
by
unknown
10:14
created

AdjacencyMatrixAggregation   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 3
dl 0
loc 59
rs 10
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the ONGR package.
5
 *
6
 * (c) NFQ Technologies UAB <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace ONGR\ElasticsearchDSL\Aggregation\Bucketing;
15
16
use ONGR\ElasticsearchDSL\Aggregation\AbstractAggregation;
17
use ONGR\ElasticsearchDSL\Aggregation\Type\BucketingTrait;
18
use ONGR\ElasticsearchDSL\BuilderInterface;
19
20
/**
21
 * Class representing adjacency matrix aggregation.
22
 *
23
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-adjacency-matrix-aggregation.html
24
 */
25
class AdjacencyMatrixAggregation extends AbstractAggregation
26
{
27
    const FILTERS = 'filters';
28
29
    use BucketingTrait;
30
31
    private array $filters = [
0 ignored issues
show
Bug introduced by
This code did not parse for me. Apparently, there is an error somewhere around this line:

Syntax error, unexpected T_ARRAY, expecting T_FUNCTION or T_CONST
Loading history...
32
        self::FILTERS => []
33
    ];
34
35
    public function __construct(string $name, array $filters = [])
36
    {
37
        parent::__construct($name);
38
39
        foreach ($filters as $name => $filter) {
40
            $this->addFilter($name, $filter);
41
        }
42
    }
43
44
    /**
45
     * @throws \LogicException
46
     */
47
    public function addFilter(string $name, BuilderInterface $filter): static
48
    {
49
        $this->filters[self::FILTERS][$name] = $filter->toArray();
50
51
        return $this;
52
    }
53
54
    public function getArray(): array
55
    {
56
        return $this->filters;
57
    }
58
59
    public function getType(): string
60
    {
61
        return 'adjacency_matrix';
62
    }
63
}
64