Completed
Pull Request — master (#141)
by
unknown
12:54
created

CustomerOrderRepository   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 23
rs 10
wmc 1
lcom 0
cbo 2

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
    public function findLastOpenOrder(Customer $param)
17
    {
18
        return $this->createQueryBuilder('o')
19
            ->join('o.customer', 'c')
20
            ->where('o.status = :opened')
21
            ->andWhere('c.id = :param')
22
            ->setParameter(':param', $param->getId())
23
            ->setParameter(':opened', CustomerOrder::STATUS_OPENED)
24
            ->orderBy('o.id', 'DESC')
25
            ->setMaxResults(1)
26
            ->getQuery()
27
            ->getOneOrNullResult()
28
            ;
29
    }
30
}
31