Completed
Push — master ( 20f6ff...6a696f )
by Nicolas
03:14
created

lib/Elastica/Processor/Date.php (1 issue)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
namespace Elastica\Processor;
3
4
/**
5
 * Elastica Date Processor.
6
 *
7
 * @author   Federico Panini <[email protected]>
8
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/date-processor.html
9
 */
10 View Code Duplication
class Date extends AbstractProcessor
0 ignored issues
show
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
11
{
12
    /**
13
     * Date constructor.
14
     *
15
     * @param string $field
16
     * @param array $formats
17
     */
18
    public function __construct(string $field, array $formats)
19
    {
20
        $this->setField($field);
21
        $this->setFormats($formats);
22
    }
23
24
    /**
25
     * Set field.
26
     *
27
     * @param string $field
28
     *
29
     * @return $this
30
     */
31
    public function setField(string $field)
32
    {
33
        return $this->setParam('field', $field);
34
    }
35
36
    /**
37
     * Set field format. Joda pattern or one of the following formats ISO8601, UNIX, UNIX_MS, or TAI64N.
38
     *
39
     * @param array $formats
40
     *
41
     * @return $this
42
     */
43
    public function setFormats(array $formats)
44
    {
45
        return $this->setParam('formats', $formats);
46
    }
47
48
    /**
49
     * Set target_field. Default value @timestamp.
50
     *
51
     * @param string $targetField
52
     *
53
     * @return $this
54
     */
55
    public function setTargetField(string $targetField)
56
    {
57
        return $this->setParam('target_field', $targetField);
58
    }
59
60
    /**
61
     * Set the timezone use when parsing the date. Default UTC.
62
     *
63
     * @param string $timezone
64
     *
65
     * @return $this
66
     */
67
    public function setTimezone(string $timezone)
68
    {
69
        return $this->setParam('timezone', $timezone);
70
    }
71
72
    /**
73
     * Set the locale to use when parsing the date.
74
     *
75
     * @param string $locale
76
     *
77
     * @return $this
78
     */
79
    public function setLocale(string $locale)
80
    {
81
        return $this->setParam('locale', $locale);
82
    }
83
}