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 ( 3564d8...305321 )
by Iakov
05:17 queued 02:25
created

RequestProcessor   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 73
Duplicated Lines 0 %

Test Coverage

Coverage 91.3%

Importance

Changes 0
Metric Value
wmc 8
dl 0
loc 73
ccs 21
cts 23
cp 0.913
rs 10
c 0
b 0
f 0
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
    public function __construct()
24
    {
25
        $this->artifacts = new ArtifactCollection();
26
    }
27
28
    /**
29
     * @param AbstractStrategy $strategy
30
     * @param Request $request
31
     * @return Response
32
     *
33
     * @throws ProcessingException
34
     */
35
    public function executeStrategy(AbstractStrategy $strategy, Request $request) : Response
36
    {
37
        while ($step = $strategy->getNextStep()) {
38
            $step->setArtifacts($this->artifacts->getRequested($step->getRequiredArtifacts()));
39
            $artifacts = $step->execute($request);
40
41
            if ($artifacts instanceof ArtifactCollection) {
42
                $artifacts->forAll(function($key, Artifact $artifact) {
43
                    if ($this->artifacts->containsKey($key)) {
44
                        throw new ProcessingException(
45
                            sprintf('Collection already contains artifact with key %s', $key)
46
                        );
47
                    }
48
                    $this->addArtifact($artifact);
49
                });
50
            }
51
        }
52
53
        return new Response(
54
            $this->getArtifact('data')->getValue(),
55
            $this->getArtifact('status')->getValue()
56
        );
57
    }
58
59
60
    /**
61
     * @param Artifact $artifact
62
     *
63
     * @return RequestProcessorInterface
64
     */
65
    public function addArtifact(Artifact $artifact): RequestProcessorInterface
66
    {
67
        $this->artifacts->add($artifact);
68
69
        return $this;
70
    }
71
72
    /**
73
     * @param string $name
74
     * @throws ProcessingException
75
     *
76
     * @return Artifact
77
     */
78
    public function getArtifact(string $name) : Artifact
79
    {
80
        $artifact = $this->artifacts->get($name)
81
        if (!$artifact instanceof Artifact) {
0 ignored issues
show
Bug introduced by
A parse error occurred: Syntax error, unexpected T_IF on line 81 at column 8
Loading history...
82
            throw new ProcessingException(sprintf('You don\'t have "%s" artifact yet', $name));
83
        }
84
85
        return $artifact;
86
    }
87
}