Completed
Push — symfony3-wololo ( 5670c9...50a832 )
by Kamil
20:37
created

ShipmentRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findOneByOrderId() 0 13 1
A findByName() 0 12 1
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\Repository\ShipmentRepositoryInterface;
16
17
class ShipmentRepository extends EntityRepository implements ShipmentRepositoryInterface
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function findOneByOrderId($id, $orderId)
23
    {
24
        $queryBuilder = $this->createQueryBuilder('o');
25
26
        return $queryBuilder
27
            ->andWhere('o.id = :id')
28
            ->andWhere('o.order = :orderId')
29
            ->setParameter('id', $id)
30
            ->setParameter('orderId', $orderId)
31
            ->getQuery()
32
            ->getOneOrNullResult()
33
        ;
34
    }
35
36
    /**
37
     * {@inheritdoc}
38
     */
39
    public function findByName($name, $locale)
40
    {
41
        return $this->createQueryBuilder('o')
42
            ->leftJoin('o.translations', 'translation')
43
            ->andWhere('translation.name = :name')
44
            ->andWhere('translation.locale = :locale')
45
            ->setParameter('name', $name)
46
            ->setParameter('localeCode', $locale)
47
            ->getQuery()
48
            ->getResult()
49
        ;
50
    }
51
}
52