Completed
Push — master ( 3d485f...407dff )
by Paweł
66:49
created

RevisionRepository::getWorkingRevision()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the Superdesk Publisher Revision Bundle.
5
 *
6
 * Copyright 2017 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú
12
 * @license http://www.superdesk.org/license
13
 */
14
15
namespace SWP\Bundle\RevisionBundle\Repository;
16
17
use Doctrine\ORM\QueryBuilder;
18
use SWP\Component\Common\Criteria\Criteria;
19
use SWP\Bundle\StorageBundle\Doctrine\ORM\EntityRepository;
20
use SWP\Component\Revision\Model\RevisionInterface;
21
use SWP\Component\Revision\Repository\RevisionRepositoryInterface;
22
23
class RevisionRepository extends EntityRepository implements RevisionRepositoryInterface
24
{
25
    /**
26
     * {@inheritdoc}
27
     */
28 View Code Duplication
    public function getPublishedRevision(): 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...
29
    {
30
        $qb = $this->getQueryByCriteria(new Criteria(), [], 'r')
31
            ->where('r.status = :status')
32
            ->setParameter('status', RevisionInterface::STATE_PUBLISHED)
33
            ->orderBy('r.publishedAt', 'desc')
34
            ->setMaxResults(1);
35
36
        return $qb;
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42 View Code Duplication
    public function getWorkingRevision(): 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...
43
    {
44
        $qb = $this->getQueryByCriteria(new Criteria(), [], 'r')
45
            ->where('r.status = :status')
46
            ->setParameter('status', RevisionInterface::STATE_NEW)
47
            ->setMaxResults(1);
48
49
        return $qb;
50
    }
51
52
    /**
53
     * {@inheritdoc}
54
     */
55
    public function getByKey($key): QueryBuilder
56
    {
57
        $qb = $this->getQueryByCriteria(new Criteria(), [], 'r')
58
            ->where('r.uniqueKey = :key')
59
            ->setParameter('key', $key);
60
61
        return $qb;
62
    }
63
}
64