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.

RequestProcessor::executeStrategy()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 10
CRAP Score 4

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 16
ccs 10
cts 10
cp 1
rs 9.9666
c 0
b 0
f 0
cc 4
nc 4
nop 2
crap 4
1
<?php
2
3
4
namespace Kami\Component\RequestProcessor;
5
6
use Symfony\Component\HttpFoundation\Request;
7
8
/**
9
 * Class RequestProcessor
10
 *
11
 * @package Kami\Component\RequestProcessor
12
 */
13
class RequestProcessor implements RequestProcessorInterface
14
{
15
    /**
16
     * @var ArtifactCollection
17
     */
18
    protected $artifacts;
19
20
    /**
21
     * RequestProcessor constructor.
22
     */
23 6
    public function __construct()
24
    {
25 6
        $this->artifacts = new ArtifactCollection();
26 6
    }
27
28
    /**
29
     * @param AbstractStrategy $strategy
30
     * @param Request $request
31
     * @return Response
32
     *
33
     * @throws ProcessingException
34
     */
35 2
    public function executeStrategy(AbstractStrategy $strategy, Request $request) : Response
36
    {
37 2
        while ($step = $strategy->getNextStep()) {
38 2
            $step->setArtifacts($this->artifacts->getRequested($step->getRequiredArtifacts()));
39 2
            $artifacts = $step->execute($request);
40
41 2
            if ($artifacts instanceof ArtifactCollection) {
42 2
                foreach ($artifacts as $artifact) {
43 2
                    $this->addArtifact($artifact);
44
                }
45
            }
46
        }
47
48 2
        return new Response(
49 2
            $this->getArtifact('data')->getValue(),
50 2
            $this->getArtifact('status')->getValue()
51
        );
52
    }
53
54
55
    /**
56
     * @param Artifact $artifact
57
     *
58
     * @return RequestProcessorInterface
59
     */
60 5
    public function addArtifact(Artifact $artifact): RequestProcessorInterface
61
    {
62 5
        $this->artifacts->add($artifact);
63
64 5
        return $this;
65
    }
66
67
    /**
68
     * @param string $name
69
     * @throws ProcessingException
70
     *
71
     * @return Artifact
72
     */
73 4
    public function getArtifact(string $name) : Artifact
74
    {
75 4
        $artifact = $this->artifacts->get($name);
76 4
        if (!$artifact instanceof Artifact) {
77 2
            throw new ProcessingException(sprintf('You don\'t have "%s" artifact yet', $name));
78
        }
79
80 3
        return $artifact;
81
    }
82
}