Completed
Pull Request — master (#1813)
by
unknown
02:40
created

ForeachProcessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 62
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 62
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setField() 0 4 1
A setProcessor() 0 4 1
A setRawProcessor() 0 4 1
A setIgnoreMissing() 0 4 1
A _getBaseName() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Foreach Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 * @author Thibaut Simon-Fine <[email protected]>
10
 *
11
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/foreach-processor.html
12
 */
13
class ForeachProcessor extends AbstractProcessor
14
{
15
    public const DEFAULT_IGNORE_MISSING_VALUE = false;
16
    protected const PROCESSOR_NAME = 'foreach';
17
18
    /**
19
     * Set field.
20
     *
21
     * @return $this
22
     */
23
    public function setField(string $field): self
24
    {
25
        return $this->setParam('field', $field);
26
    }
27
28
    /**
29
     * Set processor.
30
     *
31
     * @param AbstractProcessor
32
     *
33
     * @return $this
34
     */
35
    public function setProcessor(AbstractProcessor $processor): self
36
    {
37
        return $this->setParam('processor', $processor);
38
    }
39
40
    /**
41
     * Set raw processor.
42
     * Example : ['remove' => ['field' => 'user_agent']].
43
     *
44
     * @return $this
45
     */
46
    public function setRawProcessor(array $processor): self
47
    {
48
        return $this->setParam('processor', $processor);
49
    }
50
51
    /**
52
     * Set ignore_missing. Default value false.
53
     *
54
     * If true and field does not exist or is null, the processor quietly exits without modifying the document
55
     *
56
     * @return $this
57
     */
58
    public function setIgnoreMissing(bool $ignoreMissing): self
59
    {
60
        return $this->setParam('ignore_missing', $ignoreMissing);
61
    }
62
63
    /**
64
     * Param's name
65
     * Picks the last part of the class name and makes it snake_case
66
     * You can override this method if you want to change the name.
67
     *
68
     * @return string name
69
     */
70
    protected function _getBaseName()
71
    {
72
        return self::PROCESSOR_NAME;
73
    }
74
}
75