Completed
Pull Request — master (#1893)
by
unknown
03:25
created

ConvertProcessor   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A setField() 0 4 1
A setType() 0 4 1
A setTargetField() 0 4 1
A setIgnoreMissing() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Convert Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/convert-processor.html
11
 */
12
class ConvertProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_TARGET_FIELD_VALUE = 'field';
15
    public const DEFAULT_IGNORE_MISSING_VALUE = false;
16
17
    public function __construct(string $field, string $type)
18
    {
19
        $this->setField($field);
20
        $this->setType($type);
21
    }
22
23
    /**
24
     * Set field.
25
     *
26
     * @return $this
27
     */
28
    public function setField(string $field): self
29
    {
30
        return $this->setParam('field', $field);
31
    }
32
33
    /**
34
     * Set field value.
35
     *
36
     * @return $this
37
     */
38
    public function setType(string $type): self
39
    {
40
        return $this->setParam('type', $type);
41
    }
42
43
    /**
44
     * Set target_field. Default value field.
45
     *
46
     * @return $this
47
     */
48
    public function setTargetField(string $targetField): self
49
    {
50
        return $this->setParam('target_field', $targetField);
51
    }
52
53
    /**
54
     * Set ignore_missing. Default value false.
55
     *
56
     * @param bool $ignoreMissing only these values are allowed (integer|float|string|boolean|auto)
57
     *
58
     * @return $this
59
     */
60
    public function setIgnoreMissing(bool $ignoreMissing): self
61
    {
62
        return $this->setParam('ignore_missing', $ignoreMissing);
63
    }
64
}
65