Completed
Push — master ( dfcd91...38e980 )
by Joachim
02:37
created

PaymentRepository::findByIds()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 1
1
<?php
2
3
namespace Loevgaard\DandomainAltapayBundle\Entity;
4
5
class PaymentRepository extends EntityRepository
6
{
7
    /**
8
     * @param $id
9
     *
10
     * @return null|Payment
11
     */
12
    public function findByOrderIdOrAltapayId($id): ?Payment
13
    {
14
        /** @var Payment $payment */
15
        $payment = $this->findOneBy([
16
            'orderId' => $id,
17
        ]);
18
19
        if (!$payment) {
20
            /** @var Payment $payment */
21
            $payment = $this->findOneBy([
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $payment is correct as $this->findOneBy(array('altapayId' => $id)) (which targets Loevgaard\DandomainAltap...Repository::findOneBy()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
22
                'altapayId' => $id,
23
            ]);
24
        }
25
26
        return $payment;
27
    }
28
29
    /**
30
     * @param array $ids
31
     * @return array|Payment[]
32
     */
33
    public function findByIds(array $ids) : array
34
    {
35
        $qb = $this->getQueryBuilder('p');
36
        $qb->where($qb->expr()->in('p.id', ':ids'));
37
        $qb->setParameter('ids', $ids);
38
39
        return $qb->getQuery()->getResult();
40
    }
41
}
42