CartRepository   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 16
c 1
b 0
f 0
dl 0
loc 33
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getNonOrderedCarts() 0 8 1
A getOneNonOrderedCartByCustomer() 0 15 2
1
<?php
2
3
namespace GGGGino\SkuskuCartBundle\Repository;
4
use GGGGino\SkuskuCartBundle\Model\SkuskuCart;
5
use GGGGino\SkuskuCartBundle\Model\SkuskuCustomerInterface;
6
7
/**
8
 * CartRepository
9
 *
10
 * This class was generated by the Doctrine ORM. Add your own custom
11
 * repository methods below.
12
 */
13
class CartRepository extends \Doctrine\ORM\EntityRepository
14
{
15
    /**
16
     * Prendo tutti i carrelli attivi non eliminati
17
     */
18
    public function getNonOrderedCarts()
19
    {
20
        $qb = $this->createQueryBuilder('c')
21
            ->andWhere('c.status = :status')
22
            ->setParameter('status', SkuskuCart::STATUS_INITIAL)
23
            ->getQuery();
24
25
        return $qb->execute();
26
    }
27
28
    /**
29
     * Prendo tutti i carrelli attivi non eliminati
30
     */
31
    public function getOneNonOrderedCartByCustomer(SkuskuCustomerInterface $customer = null)
32
    {
33
        if ( !$customer ) {
34
            return null;
35
        }
36
37
        $qb = $this->createQueryBuilder('c')
38
            ->where('c.status = :status')
39
            ->andWhere('c.customer = :customer')
40
            ->setParameter('status', SkuskuCart::STATUS_INITIAL)
41
            ->setParameter('customer', $customer)
42
            ->setMaxResults(1)
43
            ->getQuery();
44
45
        return $qb->getOneOrNullResult();
46
    }
47
}
48