Test Failed
Push — master ( bdaab5...176ee2 )
by Vladimir
06:36
created

WebhookController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace FondBot\Controllers;
6
7
use FondBot\Channels\ChannelManager;
8
use FondBot\Foundation\RequestHandler;
9
use Psr\Http\Message\ResponseInterface;
10
use Psr\Http\Message\ServerRequestInterface;
11
12
class WebhookController
13
{
14
    private $channelManager;
15
    private $requestHandler;
16
17
    public function __construct(ChannelManager $channelManager, RequestHandler $requestHandler)
18
    {
19
        $this->channelManager = $channelManager;
20
        $this->requestHandler = $requestHandler;
21
    }
22
23
    public function __invoke(ServerRequestInterface $request, ResponseInterface $response, array $args): ResponseInterface
24
    {
25
        $channel = $this->channelManager->create($args['name']);
26
27
        $result = $this->requestHandler->handle($channel, $request);
28
29
        if ($result !== null) {
30
            $response->getBody()->write($result);
31
        }
32
33
        return $response->withStatus(200);
34
    }
35
}
36