Completed
Pull Request — master (#1893)
by
unknown
02:46
created

KvProcessor   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 1
dl 0
loc 84
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A setField() 0 4 1
A setFieldSplit() 0 4 1
A setValueSplit() 0 4 1
A setTargetField() 0 4 1
A setIncludeKeys() 0 4 1
A setExcludeKeys() 0 4 1
A setIgnoreMissing() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica KV Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/kv-processor.html
11
 */
12
class KvProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_TARGET_FIELD_VALUE = null;
15
    public const DEFAULT_IGNORE_MISSING_VALUE = false;
16
17
    public function __construct(string $field, string $fieldSplit, string $valueSplit)
18
    {
19
        $this->setField($field);
20
        $this->setFieldSplit($fieldSplit);
21
        $this->setValueSplit($valueSplit);
22
    }
23
24
    /**
25
     * Set field name.
26
     *
27
     * @return $this
28
     */
29
    public function setField(string $field): self
30
    {
31
        return $this->setParam('field', $field);
32
    }
33
34
    /**
35
     * Set field_split.
36
     *
37
     * @return $this
38
     */
39
    public function setFieldSplit(string $fieldSplit): self
40
    {
41
        return $this->setParam('field_split', $fieldSplit);
42
    }
43
44
    /**
45
     * Set value_split.
46
     *
47
     * @return $this
48
     */
49
    public function setValueSplit(string $valueSplit): self
50
    {
51
        return $this->setParam('value_split', $valueSplit);
52
    }
53
54
    /**
55
     * Set target_field. Default value null.
56
     *
57
     * @return $this
58
     */
59
    public function setTargetField(string $targetField): self
60
    {
61
        return $this->setParam('target_field', $targetField);
62
    }
63
64
    /**
65
     * Set include_keys.
66
     *
67
     * @return $this
68
     */
69
    public function setIncludeKeys(array $listOfKeys): self
70
    {
71
        return $this->setParam('include_keys', $listOfKeys);
72
    }
73
74
    /**
75
     * Set exclude_keys.
76
     *
77
     * @return $this
78
     */
79
    public function setExcludeKeys(array $listOfKeys): self
80
    {
81
        return $this->setParam('exclude_keys', $listOfKeys);
82
    }
83
84
    /**
85
     * Set ignore_missing. Default value false.
86
     *
87
     * @param bool $ignoreMissing only these values are allowed (integer|float|string|boolean|auto)
88
     *
89
     * @return $this
90
     */
91
    public function setIgnoreMissing(bool $ignoreMissing): self
92
    {
93
        return $this->setParam('ignore_missing', $ignoreMissing);
94
    }
95
}
96