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

CustomerOrderRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 1
lcom 0
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A findLastOpenOrder() 0 14 1
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