Code Duplication    Length = 30-30 lines in 2 locations

src/Eccube/Controller/Admin/AdminController.php 2 locations

@@ 396-425 (lines=30) @@
393
     *
394
     * @return array
395
     */
396
    protected function getSalesByMonth($em, $dateTime, array $excludes)
397
    {
398
        // concat... for pgsql
399
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
400
        $dql = 'SELECT
401
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
402
                  SUM(o.payment_total) AS order_amount,
403
                  COUNT(o) AS order_count
404
                FROM
405
                  Eccube\Entity\Order o
406
                WHERE
407
                    o.OrderStatus NOT IN (:excludes)
408
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
409
                GROUP BY
410
                  order_month';
411
412
        $q = $em
413
            ->createQuery($dql)
414
            ->setParameter(':excludes', $excludes)
415
            ->setParameter(':targetDate', $dateTime);
416
417
        $result = [];
418
        try {
419
            $result = $q->getSingleResult();
420
        } catch (NoResultException $e) {
421
            // 結果がない場合は空の配列を返す.
422
        }
423
424
        return $result;
425
    }
426
427
    /**
428
     * @param $em
@@ 434-463 (lines=30) @@
431
     *
432
     * @return array
433
     */
434
    protected function getSalesByDay($em, $dateTime, array $excludes)
435
    {
436
        // concat... for pgsql
437
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
438
        $dql = 'SELECT
439
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
440
                  SUM(o.payment_total) AS order_amount,
441
                  COUNT(o) AS order_count
442
                FROM
443
                  Eccube\Entity\Order o
444
                WHERE
445
                    o.OrderStatus NOT IN (:excludes)
446
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
447
                GROUP BY
448
                  order_day';
449
450
        $q = $em
451
            ->createQuery($dql)
452
            ->setParameter(':excludes', $excludes)
453
            ->setParameter(':targetDate', $dateTime);
454
455
        $result = [];
456
        try {
457
            $result = $q->getSingleResult();
458
        } catch (NoResultException $e) {
459
            // 結果がない場合は空の配列を返す.
460
        }
461
462
        return $result;
463
    }
464
465
    /**
466
     * @param $em