EmailLink   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 12
c 2
b 0
f 1
dl 0
loc 38
ccs 0
cts 14
cp 0
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findByToken() 0 10 2
A save() 0 5 1
A delete() 0 4 1
1
<?php
2
3
namespace Del\Repository;
4
5
use Del\Entity\EmailLink as EmailLinkEntity;
6
use Doctrine\ORM\EntityRepository;
7
8
class EmailLink extends EntityRepository
9
{
10
    /**
11
     * @param EmailLinkEntity $link
12
     * @return EmailLinkEntity
13
     * @throws \Doctrine\ORM\OptimisticLockException
14
     */
15
    public function save(EmailLinkEntity $link)
16
    {
17
        $this->_em->persist($link);
18
        $this->_em->flush();
19
        return $link;
20
    }
21
22
    /**
23
     * @param EmailLinkEntity $link
24
     * @throws \Doctrine\ORM\OptimisticLockException
25
     */
26
    public function delete(EmailLinkEntity $link)
27
    {
28
        $this->_em->remove($link);
29
        $this->_em->flush();
30
    }
31
32
    /**
33
     * @param string $token
34
     * @return EmailLinkEntity|null
35
     */
36
    public function findByToken($token)
37
    {
38
        $qb = $this->createQueryBuilder('el');
39
40
        $qb->where('el.token = :token');
41
        $qb->setParameter('token', $token);
42
43
        $query = $qb->getQuery();
44
        $result = $query->getResult();
45
        return count($result) ? $result[0] : null;
0 ignored issues
show
Bug introduced by
It seems like $result can also be of type integer; however, parameter $value of count() does only seem to accept Countable|array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

45
        return count(/** @scrutinizer ignore-type */ $result) ? $result[0] : null;
Loading history...
46
    }
47
}
48