Code Duplication    Length = 30-30 lines in 2 locations

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

@@ 332-361 (lines=30) @@
329
        return $orderArray;
330
    }
331
332
    protected function getSalesByMonth($em, $dateTime, array $excludes)
333
    {
334
        // concat... for pgsql
335
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
336
        $dql = 'SELECT
337
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) AS order_month,
338
                  SUM(o.payment_total) AS order_amount,
339
                  COUNT(o) AS order_count
340
                FROM
341
                  Eccube\Entity\Order o
342
                WHERE
343
                    o.del_flg = 0
344
                    AND o.OrderStatus NOT IN (:excludes)
345
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 7) = SUBSTRING(:targetDate, 1, 7)
346
                GROUP BY
347
                  order_month';
348
349
        $q = $em
350
            ->createQuery($dql)
351
            ->setParameter(':excludes', $excludes)
352
            ->setParameter(':targetDate', $dateTime);
353
354
        $result = array();
355
        try {
356
            $result = $q->getSingleResult();
357
        } catch (NoResultException $e) {
358
            // 結果がない場合は空の配列を返す.
359
        }
360
        return $result;
361
    }
362
363
    protected function getSalesByDay($em, $dateTime, array $excludes)
364
    {
@@ 363-392 (lines=30) @@
360
        return $result;
361
    }
362
363
    protected function getSalesByDay($em, $dateTime, array $excludes)
364
    {
365
        // concat... for pgsql
366
        // http://stackoverflow.com/questions/1091924/substr-does-not-work-with-datatype-timestamp-in-postgres-8-3
367
        $dql = 'SELECT
368
                  SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) AS order_day,
369
                  SUM(o.payment_total) AS order_amount,
370
                  COUNT(o) AS order_count
371
                FROM
372
                  Eccube\Entity\Order o
373
                WHERE
374
                    o.del_flg = 0
375
                    AND o.OrderStatus NOT IN (:excludes)
376
                    AND SUBSTRING(CONCAT(o.order_date, \'\'), 1, 10) = SUBSTRING(:targetDate, 1, 10)
377
                GROUP BY
378
                  order_day';
379
380
        $q = $em
381
            ->createQuery($dql)
382
            ->setParameter(':excludes', $excludes)
383
            ->setParameter(':targetDate', $dateTime);
384
385
        $result = array();
386
        try {
387
            $result = $q->getSingleResult();
388
        } catch (NoResultException $e) {
389
            // 結果がない場合は空の配列を返す.
390
        }
391
        return $result;
392
    }
393
394
    protected function countNonStockProducts($em)
395
    {