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
Pull Request — master (#837)
by E
07:31 queued 05:03
created

GeneratorQueue::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ApiGen\Generator;
4
5
use ApiGen\Contracts\Console\Helper\ProgressBarInterface;
6
use ApiGen\Contracts\Generator\GeneratorQueueInterface;
7
use ApiGen\Contracts\Generator\StepCounterInterface;
8
use ApiGen\Contracts\Generator\TemplateGenerators\ConditionalTemplateGeneratorInterface;
9
use ApiGen\Contracts\Generator\TemplateGenerators\TemplateGeneratorInterface;
10
11
final class GeneratorQueue implements GeneratorQueueInterface
12
{
13
    /**
14
     * @var ProgressBarInterface
15
     */
16
    private $progressBar;
17
18
    /**
19
     * @var TemplateGeneratorInterface[]
20
     */
21
    private $queue = [];
22
23 8
    public function __construct(ProgressBarInterface $progressBar)
24
    {
25 8
        $this->progressBar = $progressBar;
26 8
    }
27
28 2
    public function run(): void
29
    {
30 2
        $this->progressBar->init($this->getStepCount());
31
32 2
        foreach ($this->getAllowedQueue() as $templateGenerator) {
33 2
            $templateGenerator->generate();
34
        }
35 2
    }
36
37 8
    public function addToQueue(TemplateGeneratorInterface $templateGenerator): void
38
    {
39 8
        $this->queue[] = $templateGenerator;
40 8
    }
41
42
    /**
43
     * @return TemplateGeneratorInterface[]
44
     */
45
    private function getAllowedQueue(): array
46
    {
47 4
        return array_filter($this->queue, function (TemplateGeneratorInterface $generator) {
48 4
            if ($generator instanceof ConditionalTemplateGeneratorInterface) {
49 1
                return $generator->isAllowed();
50
            }
51
52 3
            return true;
53 4
        });
54
    }
55
56 3
    private function getStepCount(): int
57
    {
58 3
        $steps = 0;
59 3
        foreach ($this->getAllowedQueue() as $templateGenerator) {
60 3
            if ($templateGenerator instanceof StepCounterInterface) {
61 2
                $steps += $templateGenerator->getStepCount();
62
            }
63
        }
64
65 3
        return $steps;
66
    }
67
}
68