Completed
Push — master ( 3ff7e6...cf5edc )
by Kamil
96:30 queued 63:14
created

AddressRepository::findOneByCustomerAndId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
dl 0
loc 12
rs 9.4285
c 1
b 1
f 0
cc 1
eloc 9
nc 1
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Sylius package.
5
 *
6
 * (c) Paweł Jędrzejewski
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Sylius\Bundle\CoreBundle\Doctrine\ORM;
13
14
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
15
use Sylius\Component\Core\Model\CustomerInterface;
16
use Sylius\Component\Core\Repository\AddressRepositoryInterface;
17
18
/**
19
 * @author Anna Walasek <[email protected]>
20
 * @author Jan Góralski <[email protected]>
21
 */
22
class AddressRepository extends EntityRepository implements AddressRepositoryInterface
23
{
24
    /**
25
     * {@inheritdoc}
26
     */
27
    public function findByCustomer(CustomerInterface $customer)
28
    {
29
        return $this->createQueryBuilder('o')
30
            ->leftJoin('o.customer', 'customer')
31
            ->where('customer = :customer')
32
            ->setParameter('customer', $customer)
33
            ->getQuery()
34
            ->getResult()
35
        ;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function findOneByCustomerAndId(CustomerInterface $customer, $id)
42
    {
43
        return $this->createQueryBuilder('o')
44
            ->leftJoin('o.customer', 'customer')
45
            ->where('customer = :customer')
46
            ->andWhere('o.id = :id')
47
            ->setParameter('customer', $customer)
48
            ->setParameter('id', $id)
49
            ->getQuery()
50
            ->getOneOrNullResult()
51
        ;
52
    }
53
}
54