Completed
Pull Request — master (#147)
by
unknown
22:02 queued 07:21
created

CustomerOrderRepository::findLastOpenOrder()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 14
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 1
eloc 11
c 1
b 1
f 0
nc 1
nop 1
dl 0
loc 14
ccs 11
cts 11
cp 1
crap 1
rs 9.4285
1
<?php
2
3
namespace AppBundle\Repository;
4
5
use AppBundle\Entity\Customer;
6
use AppBundle\Entity\CustomerOrder;
7
8
class CustomerOrderRepository extends AbstractRepository
9
{
10
    /**
11
     * Method returns opened customer order
12
     *
13
     * @param Customer $param
14
     * @return CustomerOrder|null
15
     */
16 1
    public function findLastOpenOrder(Customer $param)
17
    {
18 1
        return $this->createQueryBuilder('o')
19 1
            ->join('o.customer', 'c')
20 1
            ->where('o.status = :opened')
21 1
            ->andWhere('c.id = :param')
22 1
            ->setParameter(':param', $param->getId())
23 1
            ->setParameter(':opened', CustomerOrder::STATUS_OPENED)
24 1
            ->orderBy('o.id', 'DESC')
25 1
            ->setMaxResults(1)
26 1
            ->getQuery()
27 1
            ->getOneOrNullResult()
28
            ;
29
    }
30
}
31