Passed
Push — master ( 95786b...34331f )
by Paweł
05:27 queued 02:18
created

KernelClient::request()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 2
b 0
f 0
nc 1
nop 3
dl 0
loc 6
ccs 5
cts 5
cp 1
crap 1
rs 10
1
<?php
2
/**
3
 * Copyright (c) 2020.
4
 * @author Paweł Antosiak <[email protected]>
5
 */
6
7
declare(strict_types=1);
8
9
namespace Gorynych\Http;
10
11
use Symfony\Component\HttpFoundation\Response;
12
13
final class KernelClient
14
{
15
    private Kernel $kernel;
16
    private RequestFactoryInterface $requestFactory;
17
    private ?Response $response;
18
19 1
    public function __construct(Kernel $kernel, RequestFactoryInterface $requestFactory)
20
    {
21 1
        $this->kernel = $kernel;
22 1
        $this->requestFactory = $requestFactory;
23 1
    }
24
25
    /**
26
     * Performs request on the kernel
27
     *
28
     * @param string $method
29
     * @param string $uri
30
     * @param string[][] $options
31
     * @return Response
32
     */
33 1
    public function request(string $method, string $uri, array $options = []): Response
34
    {
35 1
        return $this->response = $this->kernel
36 1
            ->reboot()
37 1
            ->handleRequest(
38 1
                $this->requestFactory->create($method, $uri, $options)
39
            );
40
    }
41
42
    public function getResponse(): ?Response
43
    {
44
        return $this->response;
45
    }
46
}
47