Completed
Push — master ( 0d8778...4693cf )
by Derek Stephen
05:55
created

EmailLink::save()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 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
     */
14 4
    public function save(EmailLinkEntity $link)
15
    {
16 4
        $this->_em->persist($link);
17 4
        $this->_em->flush();
18 4
        return $link;
19
    }
20
    /**
21
     * @param EmailLinkEntity $link
22
     */
23 4
    public function delete(EmailLinkEntity $link)
24
    {
25 4
        $this->_em->remove($link);
26 4
        $this->_em->flush();
27 4
    }
28
29
    /**
30
     * @param string $token
31
     * @return EmailLinkEntity|null
32
     */
33 4
    public function findByToken($token)
34
    {
35 4
        $qb = $this->createQueryBuilder('el');
36
37 4
        $qb->where('el.token = :token');
38 4
        $qb->setParameter('token', $token);
39
40 4
        $query = $qb->getQuery();
41 4
        $result = $query->getResult();
42 4
        return count($result) ? $result[0] : null;
43
    }
44
}
45