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

EmailLink::delete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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