Code Duplication    Length = 15-15 lines in 2 locations

Model/PublicationQuery.php 2 locations

@@ 77-91 (lines=15) @@
74
     * @return PublicationQuery
75
     * @throws \Exception
76
     */
77
    public function filterByYear($value)
78
    {
79
        if (is_null($value)) {
80
            return $this;
81
        }
82
83
        if (!preg_match('/^\d{4}$/', $value)) {
84
            throw new \Exception('Incorrect year value: '. $value);
85
        }
86
87
        return $this->filterByCreatedAt(array(
88
            'min' => $value .'-01-01 00:00:00',
89
            'max' => $value .'-12-31 23:59:59'
90
        ));
91
    }
92
93
    /**
94
     * Applies the filter by month
@@ 125-139 (lines=15) @@
122
     * @return PublicationQuery
123
     * @throws \Exception
124
     */
125
    public function filterByDay($value)
126
    {
127
        if (is_null($value)) {
128
            return $this;
129
        }
130
131
        if (!preg_match('/^\d{4}\-\d{2}\-\d{2}$/', $value)) {
132
            throw new \Exception('Incorrect day value: '. $value);
133
        }
134
135
        return $this->filterByCreatedAt(array(
136
            'min' => $value .' 00:00:00',
137
            'max' => $value .' 23:59:59'
138
        ));
139
    }
140
}
141