Completed
Pull Request — master (#1893)
by
unknown
06:15 queued 02:30
created

JsonProcessor   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setField() 0 4 1
A setTargetField() 0 4 1
A setAddToRoot() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Json Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/reference/current/json-processor.html
11
 */
12
class JsonProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_TARGET_FIELD_VALUE = 'field';
15
    public const DEFAULT_ADD_TO_ROOT_VALUE = false;
16
17
    public function __construct(string $field)
18
    {
19
        $this->setField($field);
20
    }
21
22
    /**
23
     * Set the field.
24
     *
25
     * @return $this
26
     */
27
    public function setField(string $field): self
28
    {
29
        return $this->setParam('field', $field);
30
    }
31
32
    /**
33
     * Set target_field. Default field.
34
     *
35
     * @return $this
36
     */
37
    public function setTargetField(string $targetField): self
38
    {
39
        return $this->setParam('target_field', $targetField);
40
    }
41
42
    /**
43
     * Set add_to_root. Default value false.
44
     *
45
     * @return $this
46
     */
47
    public function setAddToRoot(bool $addToRoot): self
48
    {
49
        return $this->setParam('add_to_root', $addToRoot);
50
    }
51
}
52