Completed
Push — master ( 6cd8ca...cbb2b9 )
by Paweł
63:35
created

ApiKeyRepository::getValidTokenForUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 7

Duplication

Lines 10
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
ccs 0
cts 0
cp 0
rs 9.4285
cc 1
eloc 7
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Superdesk Web Publisher Core Bundle.
7
 *
8
 * Copyright 2016 Sourcefabric z.ú. and contributors.
9
 *
10
 * For the full copyright and license information, please see the
11
 * AUTHORS and LICENSE files distributed with this source code.
12
 *
13
 * @copyright 2016 Sourcefabric z.ú
14
 * @license http://www.superdesk.org/license
15
 */
16
17
namespace SWP\Bundle\CoreBundle\Repository;
18
19
use Doctrine\ORM\QueryBuilder;
20
use SWP\Bundle\CoreBundle\Model\UserInterface;
21
use SWP\Component\Common\Criteria\Criteria;
22
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
23
24
class ApiKeyRepository extends EntityRepository implements ApiKeyRepositoryInterface
25
{
26
    /**
27
     * {@inheritdoc}
28 76
     */
29 View Code Duplication
    public function getValidToken(string $token): QueryBuilder
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
30 76
    {
31 76
        $qb = $this->getQueryByCriteria(new Criteria(['apiKey' => $token]), [], 'ak')
32 76
            ->leftJoin('ak.user', 'u')
33
            ->addSelect('u')
34 76
            ->andWhere('ak.validTo >= :now')
35
            ->setParameter('now', new \DateTime());
36
37
        return $qb;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43 View Code Duplication
    public function getValidTokenForUser(UserInterface $user)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44
    {
45
        $qb = $this->getQueryByCriteria(new Criteria(['user' => $user]), [], 'ak')
46
            ->leftJoin('ak.user', 'u')
47
            ->addSelect('u')
48
            ->andWhere('ak.validTo >= :now')
49
            ->setParameter('now', new \DateTime());
50
51
        return $qb;
52
    }
53
}
54