Failed Conditions
Push — master ( ee6ce9...9ed6ac )
by Yangsin
485:10 queued 475:23
created

OrderStatusRepository::findNotContainsBy()   C

Complexity

Conditions 7
Paths 16

Size

Total Lines 28
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 22
CRAP Score 7

Importance

Changes 0
Metric Value
dl 0
loc 28
ccs 22
cts 22
cp 1
rs 6.7272
c 0
b 0
f 0
cc 7
eloc 16
nc 16
nop 4
crap 7
1
<?php
2
/*
3
 * This file is part of EC-CUBE
4
 *
5
 * Copyright(c) 2000-2015 LOCKON CO.,LTD. All Rights Reserved.
6
 *
7
 * http://www.lockon.co.jp/
8
 *
9
 * This program is free software; you can redistribute it and/or
10
 * modify it under the terms of the GNU General Public License
11
 * as published by the Free Software Foundation; either version 2
12
 * of the License, or (at your option) any later version.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17
 * GNU General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU General Public License
20
 * along with this program; if not, write to the Free Software
21
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
 */
23
24
25
namespace Eccube\Repository\Master;
26
27
use Doctrine\ORM\EntityRepository;
28
use Doctrine\ORM\Query;
29
30
/**
31
 * OrderStatusRepository
32
 *
33
 * This class was generated by the Doctrine ORM. Add your own custom
34
 * repository methods below.
35
 */
36
class OrderStatusRepository extends EntityRepository
37
{
38
    /**
39
     * NOT IN で検索する.
40
     *
41
     * TODO Abstract メソッドにしたい
42
     *
43
     * @param array $criteria
0 ignored issues
show
introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
44
     * @param array $orderBy
0 ignored issues
show
introduced by
Expected 3 spaces after parameter type; 1 found
Loading history...
45
     * @param integer $limit
46
     * @param integer $offset
47
     * @return array
48
     * @see EntityRepository::findBy()
49
     */
50 35
    public function findNotContainsBy(array $criteria, array $orderBy = null, $limit = null, $offset = null)
51
    {
52 35
        $qb = $this->createQueryBuilder('o');
53
54 35
        foreach ($criteria as $col => $val) {
55 30
            $qb->andWhere($qb->expr()->notIn('o.'.$col, ':'.$col))
56 30
                ->setParameter($col, (array)$val);
0 ignored issues
show
Coding Style introduced by
As per coding-style, a cast statement should be followed by a single space.
Loading history...
57 35
        }
58
59 35
        if (is_array($orderBy)) {
60 4
            foreach ($orderBy as $sort => $order) {
61 4
                if (array_values($orderBy) === $orderBy) { // 配列 or 連想配列
62 3
                    $sort = $order;
63 3
                    $order = 'ASC';
64 3
                }
65 4
                $qb->orderBy('o.'.$sort, $order);
66 4
            }
67 4
        }
68
69 35
        if ($limit > 0) {
70 2
            $qb->setMaxResults($limit);
71 2
        }
72 35
        if ($offset > 0) {
73 1
            $qb->setFirstResult($offset);
74 1
        }
75
76 35
        return $qb->getQuery()->getResult();
77
    }
78
79
    public function findAllArray()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
80
    {
81
82
        $query = $this
83
            ->getEntityManager()
84
            ->createQuery('SELECT os FROM Eccube\Entity\Master\OrderStatus os INDEX BY os.id ORDER BY os.rank ASC')
85
        ;
86
        $result = $query
87
            ->getResult(Query::HYDRATE_ARRAY)
88
        ;
89
90
        return $result;
91
92
    }
93
}
94