Code Duplication    Length = 21-22 lines in 2 locations

htdocs/xoops_lib/Xoops/Core/Locale/Time.php 2 locations

@@ 284-305 (lines=22) @@
281
        $formatChars = static::utf8StringToChars($dateFormat);
282
        $state = 'non';
283
        $newstate = $state;
284
        foreach ($formatChars as $char) {
285
            switch ($char) {
286
                case 'y':
287
                    $newstate = 'y';
288
                    break;
289
                case 'M':
290
                    $newstate = 'm';
291
                    break;
292
                case 'd':
293
                    $newstate = 'd';
294
                    break;
295
                default:
296
                    $newstate = 'non';
297
                    break;
298
            }
299
            if ($newstate !== $state) {
300
                if (in_array($newstate, ['y', 'm', 'd'])) {
301
                    $order[] = $newstate;
302
                }
303
                $state = $newstate;
304
            }
305
        }
306
307
        $pieces = [];
308
        $pieceIndex = -1;
@@ 392-412 (lines=21) @@
389
        $formatChars = static::utf8StringToChars($timeFormat);
390
        $state = 'non';
391
        $newstate = $state;
392
        foreach ($formatChars as $char) {
393
            switch ($char) {
394
                case 'h':
395
                case 'H':
396
                    $newstate = 'h';
397
                    break;
398
                case 'm':
399
                    $newstate = 'm';
400
                    break;
401
                case 'a':
402
                default:
403
                    $newstate = 'non';
404
                    break;
405
            }
406
            if ($newstate !== $state) {
407
                if (in_array($newstate, ['h', 'm'])) {
408
                    $order[] = $newstate;
409
                }
410
                $state = $newstate;
411
            }
412
        }
413
414
        $pieces = [];
415
        $pieceIndex = -1;