Code Duplication    Length = 47-47 lines in 2 locations

app/module/Albums/One/Album.php 1 location

@@ 132-178 (lines=47) @@
129
     * 
130
     * @return string If date field empty, return current date
131
     */
132
    public function date($format = false, $style = 'normal', $inflected = true)
133
    {
134
        $date = $this->album['date'];
135
136
        $validator = new Validator();
137
        $validator->checkDatetime('date', $date, 'Y-m-d H:i:s');
138
        if ($validator->isErrors() or empty($date)) {
139
            return $date;
140
        }
141
142
        switch ($style) {
143
            case 'locale': // http://php.net/manual/en/function.strftime.php
144
                $format = ($format) ? $format : '%D';
145
                $date = strftime($format, strtotime($date));
146
                break;
147
148
            default: // http://php.net/manual/en/datetime.formats.date.php
149
                $format = ($format) ? $format : 'Y-m-d H:i:s';
150
                $date = date_format(date_create($date), $format);
151
                break;
152
        }
153
154
        $date = Hooks\Filter::apply('date_format_filter', $date);
155
156
        if (true === $inflected) {
157
            $month = [
158
                'styczeń' => 'stycznia', // 01
159
                'luty' => 'lutego', // 02
160
                'marzec' => 'marca', // 03
161
                'kwiecień' => 'kwietnia', // 04
162
                'maj' => 'maja', // 05
163
                'czerwiec' => 'czerwca', // 06
164
                'lipiec' => 'lipca', // 07
165
                'sierpień' => 'sierpnia', // 08
166
                'wrzesień' => 'września', // 09
167
                'październik' => 'października', // 10
168
                'listopad' => 'listopada', // 11
169
                'grudzień' => 'grudnia', // 12
170
            ];
171
172
            foreach ($month as $key => $value) {
173
                $date = str_replace($key, $value, $date);
174
            }
175
        }
176
177
        return $date;
178
    }
179
180
    /**
181
     * Returns date of album added.

app/module/Articles/One/Article.php 1 location

@@ 205-251 (lines=47) @@
202
     * 
203
     * @return string If date field empty, return current date
204
     */
205
    public function date($format = false, $style = 'normal', $inflected = true)
206
    {
207
        $date = $this->article['date'];
208
209
        $validator = new Validator();
210
        $validator->checkDatetime('date', $date, 'Y-m-d H:i:s');
211
        if ($validator->isErrors() or empty($date)) {
212
            return $date;
213
        }
214
215
        switch ($style) {
216
            case 'locale': // http://php.net/manual/en/function.strftime.php
217
                $format = ($format) ? $format : '%D';
218
                $date = strftime($format, strtotime($date));
219
                break;
220
221
            default: // http://php.net/manual/en/datetime.formats.date.php
222
                $format = ($format) ? $format : 'Y-m-d H:i:s';
223
                $date = date_format(date_create($date), $format);
224
                break;
225
        }
226
227
        $date = Hooks\Filter::apply('date_format_filter', $date);
228
229
        if (true === $inflected) {
230
            $month = [
231
                'styczeń' => 'stycznia', // 01
232
                'luty' => 'lutego', // 02
233
                'marzec' => 'marca', // 03
234
                'kwiecień' => 'kwietnia', // 04
235
                'maj' => 'maja', // 05
236
                'czerwiec' => 'czerwca', // 06
237
                'lipiec' => 'lipca', // 07
238
                'sierpień' => 'sierpnia', // 08
239
                'wrzesień' => 'września', // 09
240
                'październik' => 'października', // 10
241
                'listopad' => 'listopada', // 11
242
                'grudzień' => 'grudnia', // 12
243
            ];
244
245
            foreach ($month as $key => $value) {
246
                $date = str_replace($key, $value, $date);
247
            }
248
        }
249
250
        return $date;
251
    }
252
253
    /**
254
     * Returns date of article added.