Completed
Push — legacy ( c3f933 )
by Simonas
95:41
created

NotFilter   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 6
c 2
b 1
f 0
lcom 1
cbo 2
dl 0
loc 62
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getFilter() 0 4 1
A setFilter() 0 4 1
A __construct() 0 7 2
A toArray() 0 9 1
A getType() 0 4 1
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
namespace ONGR\ElasticsearchBundle\DSL\Filter;
13
14
use ONGR\ElasticsearchBundle\DSL\BuilderInterface;
15
use ONGR\ElasticsearchBundle\DSL\ParametersTrait;
16
17
/**
18
 * Represents Elasticsearch "not" filter.
19
 *
20
 * @link http://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-not-filter.html
21
 */
22
class NotFilter implements BuilderInterface
23
{
24
    use ParametersTrait;
25
26
    /**
27
     * @var BuilderInterface
28
     */
29
    private $filter;
30
31
    /**
32
     * @param BuilderInterface $filter     Filter.
33
     * @param array            $parameters Optional parameters.
34
     */
35
    public function __construct(BuilderInterface $filter = null, array $parameters = [])
36
    {
37
        if ($filter !== null) {
38
            $this->setFilter($filter);
39
        }
40
        $this->setParameters($parameters);
41
    }
42
    
43
    /**
44
     * Returns filter.
45
     *
46
     * @return BuilderInterface
47
     */
48
    public function getFilter()
49
    {
50
        return $this->filter;
51
    }
52
53
    /**
54
     * Sets filter.
55
     *
56
     * @param BuilderInterface $filter
57
     */
58
    public function setFilter(BuilderInterface $filter)
59
    {
60
        $this->filter = $filter;
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getType()
67
    {
68
        return 'not';
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function toArray()
75
    {
76
        $query = [];
77
        $query['filter'] = [$this->filter->getType() => $this->filter->toArray()];
78
79
        $output = $this->processArray($query);
80
81
        return $output;
82
    }
83
}
84