Conditions | 7 |
Paths | 10 |
Total Lines | 25 |
Code Lines | 13 |
Lines | 0 |
Ratio | 0 % |
Tests | 15 |
CRAP Score | 7 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
50 | 6 | public function __invoke(Request $request, Response $response, $args) |
|
51 | { |
||
52 | 6 | $body = $request->getParsedBody(); |
|
53 | 6 | if ( ! isset($body['object_kind'])) { |
|
54 | 1 | return $response->withStatus(500); |
|
55 | } |
||
56 | |||
57 | 5 | foreach ($request->getHeader('X-Gitlab-Token') as $secret) { |
|
58 | 4 | if ($secret == $this->secret) { // allow cast |
|
59 | 4 | $this->secured = TRUE; |
|
60 | 4 | } |
|
61 | 5 | } |
|
62 | |||
63 | 5 | if ($this->secret !== NULL && ! $this->secured) { |
|
64 | 1 | return $response->withStatus(403); |
|
65 | } |
||
66 | |||
67 | 4 | if (isset($this->router[$body['object_kind']])) { |
|
68 | 3 | $this->router[$body['object_kind']]($body); |
|
69 | 3 | return $response->withStatus(200); |
|
70 | } |
||
71 | |||
72 | |||
73 | 1 | return $response->withStatus(404); |
|
74 | } |
||
75 | |||
77 |