GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 0097ae...d93d91 )
by Андрей
02:02
created

StepRepository::findHistorySteps()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 21
Code Lines 7

Duplication

Lines 21
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 21
loc 21
rs 9.3142
cc 1
eloc 7
nc 1
nop 1
1
<?php
2
/**
3
 * @link    https://github.com/old-town/workflow-doctrine
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\Spi\Doctrine\EntityRepository;
7
8
use Doctrine\ORM\EntityRepository;
9
use OldTown\Workflow\Spi\Doctrine\Entity\StepInterface;
10
use OldTown\Workflow\Spi\Doctrine\Entity\EntryInterface;
11
12
class StepRepository extends EntityRepository
13
{
14
    /**
15
     * @param array $listId
16
     *
17
     * @return array
18
     *
19
     * @throws Exception\RuntimeException
20
     */
21
    public function findByIds(array $listId = [])
22
    {
23
        $countListId = count($listId);
24
        if (0 === $countListId) {
25
            return [];
26
        }
27
28
        $dql = sprintf(
29
            'SELECT s FROM %s s WHERE s.id IN (:stepIds)',
30
            $this->_entityName
31
        );
32
33
        $query = $this->_em->createQuery($dql);
34
        $query->setParameter('stepIds', $listId);
35
36
        /** @var StepInterface[] $steps */
37
        $steps = $query->getResult();
38
39
        if ($countListId !== count($steps)) {
40
            $errMsg = 'error search step';
41
            throw new Exception\RuntimeException($errMsg);
42
        }
43
44
        return $steps;
45
    }
46
47
    /**
48
     * Поиск текущих шагов
49
     *
50
     * @param EntryInterface $entry
51
     *
52
     * @return array
53
     */
54 View Code Duplication
    public function findCurrentSteps(EntryInterface $entry)
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...
55
    {
56
        $dql = "
57
          SELECT
58
            step
59
          FROM {$this->_entityName} step
60
          JOIN step.entry entry
61
          WHERE
62
              entry.id = :entryId
63
                AND
64
              step.type = :stepType
65
          ";
66
67
        $query = $this->_em->createQuery($dql);
68
        $query->setParameter('entryId', $entry->getId());
69
        $query->setParameter('stepType', StepInterface::CURRENT_STEP);
70
71
        /** @var StepInterface[] $steps */
72
        return $query->getResult();
73
    }
74
75
    /**
76
     * Поиск шагов в истории
77
     *
78
     * @param EntryInterface $entry
79
     *
80
     * @return array
81
     */
82 View Code Duplication
    public function findHistorySteps(EntryInterface $entry)
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...
83
    {
84
        $dql = "
85
          SELECT
86
            step
87
          FROM {$this->_entityName} step
88
          JOIN step.entry entry
89
          WHERE
90
              entry.id = :entryId
91
                AND
92
              step.type = :stepType
93
          ORDER BY step.finishDate ASC
94
          ";
95
96
        $query = $this->_em->createQuery($dql);
97
        $query->setParameter('entryId', $entry->getId());
98
        $query->setParameter('stepType', StepInterface::HISTORY_STEP);
99
100
        /** @var StepInterface[] $steps */
101
        return $query->getResult();
102
    }
103
}
104