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

lib/Elastica/Processor/DateIndexName.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 DateIndexName Processor.
6
 *
7
 * @author   Federico Panini <[email protected]>
8
 * @link https://www.elastic.co/guide/en/elasticsearch/reference/current/date-index-name-processor.html
9
 */
10 View Code Duplication
class DateIndexName 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
     * DateIndexName constructor.
14
     *
15
     * @param string $field
16
     * @param string $dateRounding
17
     */
18
    public function __construct(string $field, string $dateRounding)
19
    {
20
        $this->setField($field);
21
        $this->setDateRounding($dateRounding);
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 date_rounding. Valid values are: y (year), M (month), w (week), d (day), h (hour), m (minute) and s (second).
38
     *
39
     * @param string $dateRounding
40
     *
41
     * @return $this
42
     */
43
    public function setDateRounding(string $dateRounding)
44
    {
45
        return $this->setParam('date_rounding', $dateRounding);
46
    }
47
48
    /**
49
     * Set field formats. Joda pattern or one of the following formats ISO8601, UNIX, UNIX_MS, or TAI64N.
50
     *
51
     * @param array $formats
52
     *
53
     * @return $this
54
     */
55
    public function setDateFormats(array $formats)
56
    {
57
        return $this->setParam('date_formats', $formats);
58
    }
59
60
    /**
61
     * Set index_prefix_name.
62
     *
63
     * @param string $indexPrefixName
64
     *
65
     * @return $this
66
     */
67
    public function setIndexNamePrefix(string $indexPrefixName)
68
    {
69
        return $this->setParam('index_name_prefix', $indexPrefixName);
70
    }
71
72
    /**
73
     * Set format to be used when printing parsed date. An valid Joda pattern is expected here. Default yyyy-MM-dd
74
     *
75
     * @param string $indexNameFormat
76
     *
77
     * @return $this
78
     */
79
    public function setIndexNameFormat(string $indexNameFormat)
80
    {
81
        return $this->setParam('index_name_format', $indexNameFormat);
82
    }
83
84
    /**
85
     * Set the timezone use when parsing the date. Default UTC.
86
     *
87
     * @param string $timezone
88
     *
89
     * @return $this
90
     */
91
    public function setTimezone(string $timezone)
92
    {
93
        return $this->setParam('timezone', $timezone);
94
    }
95
96
    /**
97
     * Set the locale to use when parsing the date.
98
     *
99
     * @param string $locale
100
     *
101
     * @return $this
102
     */
103
    public function setLocale(string $locale)
104
    {
105
        return $this->setParam('locale', $locale);
106
    }
107
}