Completed
Push — master ( a12959...164d8d )
by Mario
03:20
created

NativeRequestManager::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 4
Bugs 0 Features 0
Metric Value
c 4
b 0
f 0
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Marek\Toggable\Http\Manager;
4
5
use Marek\Toggable\API\Exception\Http\BaseException;
6
use Marek\Toggable\API\Exception\NotFoundException;
7
8
/**
9
 * Class NativeRequestManager
10
 * @package Marek\Toggable\Http\Manager
11
 */
12
class NativeRequestManager implements RequestManagerInterface
13
{
14
    /**
15
     * @var \Marek\Toggable\Http\Client\HttpClientInterface
16
     */
17
    private $client;
18
19
    /**
20
     * NativeRequestManager constructor.
21
     *
22
     * @param \Marek\Toggable\Http\Client\HttpClientInterface $client
23
     */
24 17
    public function __construct(\Marek\Toggable\Http\Client\HttpClientInterface $client)
25
    {
26 17
        $this->client = $client;
27 17
    }
28
29
    /**
30
     * {@inheritdoc}
31
     */
32 2
    public function request(\Marek\Toggable\API\Http\Request\RequestInterface $request)
33
    {
34
        try {
35
36 2
            $this->client->prepare($request);
37 2
            $response = $this->client->getResponse();
38
39 2
        } catch (BaseException $e) {
40
41 1
            throw new NotFoundException(get_class($request));
42
43
        }
44
45 1
        return $response;
46
    }
47
}
48