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

AttachmentProcessor   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 61
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 1
dl 0
loc 61
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A setField() 0 4 1
A setTargetField() 0 4 1
A setIndexedChars() 0 4 1
A setProperties() 0 4 1
A setIgnoreMissing() 0 4 1
1
<?php
2
3
namespace Elastica\Processor;
4
5
/**
6
 * Elastica Attachment Processor.
7
 *
8
 * @author Federico Panini <[email protected]>
9
 *
10
 * @see https://www.elastic.co/guide/en/elasticsearch/plugins/current/ingest-attachment.html
11
 */
12
class AttachmentProcessor extends AbstractProcessor
13
{
14
    public const DEFAULT_TARGET_FIELD_VALUE = 'attachment';
15
    public const DEFAULT_INDEXED_CHARS_VALUE = 100000;
16
    public const DEFAULT_IGNORE_MISSING_VALUE = false;
17
18
    public function __construct(string $field)
19
    {
20
        $this->setField($field);
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 target_field. Default attachment.
35
     *
36
     * @return $this
37
     */
38
    public function setTargetField(string $targetField): self
39
    {
40
        return $this->setParam('target_field', $targetField);
41
    }
42
43
    /**
44
     * Set indexed_chars. Default 100000.
45
     *
46
     * @return $this
47
     */
48
    public function setIndexedChars(int $indexedChars): self
49
    {
50
        return $this->setParam('indexed_chars', $indexedChars);
51
    }
52
53
    /**
54
     * Set properties. Default all properties. Can be content, title, name, author, keywords, date, content_type, content_length, language.
55
     *
56
     * @return $this
57
     */
58
    public function setProperties(array $properties): self
59
    {
60
        return $this->setParam('properties', $properties);
61
    }
62
63
    /**
64
     * Set ignore_missing. Default value false.
65
     *
66
     * @return $this
67
     */
68
    public function setIgnoreMissing(bool $ignoreMissing): self
69
    {
70
        return $this->setParam('ignore_missing', $ignoreMissing);
71
    }
72
}
73