Completed
Push — master ( 982b78...b754a4 )
by Derek Stephen
12:37
created

EmailLink   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 46.67%

Importance

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

3 Methods

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