Completed
Push — master ( bbd5c2...15f243 )
by Derek Stephen
01:52
created

EmailLink   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 4
dl 0
loc 40
ccs 15
cts 15
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A findByToken() 0 11 2
A save() 0 6 1
A delete() 0 5 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 4
    public function save(EmailLinkEntity $link)
16
    {
17 4
        $this->_em->persist($link);
18 4
        $this->_em->flush();
19 4
        return $link;
20
    }
21
22
    /**
23
     * @param EmailLinkEntity $link
24
     * @throws \Doctrine\ORM\OptimisticLockException
25
     */
26 4
    public function delete(EmailLinkEntity $link)
27
    {
28 4
        $this->_em->remove($link);
29 4
        $this->_em->flush();
30 4
    }
31
32
    /**
33
     * @param string $token
34
     * @return EmailLinkEntity|null
35
     */
36 4
    public function findByToken($token)
37
    {
38 4
        $qb = $this->createQueryBuilder('el');
39
40 4
        $qb->where('el.token = :token');
41 4
        $qb->setParameter('token', $token);
42
43 4
        $query = $qb->getQuery();
44 4
        $result = $query->getResult();
45 4
        return count($result) ? $result[0] : null;
46
    }
47
}
48