Completed
Push — master ( 97eb33...e94ecf )
by Mikołaj
03:40
created

InvoiceRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findByOrderId() 0 10 1
A findOneByTokenValue() 0 10 1
1
<?php
2
3
/*
4
 * This file has been created by developers from BitBag.
5
 * Feel free to contact us once you face any issues or want to start
6
 * another great project.
7
 * You can find more information about us on https://bitbag.shop and write us
8
 * an email on [email protected].
9
 */
10
11
declare(strict_types=1);
12
13
namespace BitBag\SyliusInvoicingPlugin\Repository;
14
15
use BitBag\SyliusInvoicingPlugin\Entity\InvoiceInterface;
16
use Sylius\Bundle\ResourceBundle\Doctrine\ORM\EntityRepository;
17
18
final class InvoiceRepository extends EntityRepository implements InvoiceRepositoryInterface
19
{
20
    public function findByOrderId(?int $orderId): ?InvoiceInterface
21
    {
22
        return $this->createQueryBuilder('o')
23
            ->innerJoin('o.order', 'invoiceOrder')
24
            ->where('invoiceOrder.id = :orderId')
25
            ->setParameter('orderId', $orderId)
26
            ->getQuery()
27
            ->getOneOrNullResult()
28
        ;
29
    }
30
31
    public function findOneByTokenValue(string $tokenValue): ?InvoiceInterface
32
    {
33
        return $this->createQueryBuilder('o')
34
            ->innerJoin('o.order', 'invoiceOrder')
35
            ->where('invoiceOrder.tokenValue = :tokenValue')
36
            ->setParameter('tokenValue', $tokenValue)
37
            ->getQuery()
38
            ->getOneOrNullResult()
39
        ;
40
    }
41
}
42