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

NativeRequestManager   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
wmc 3
c 4
b 0
f 0
lcom 1
cbo 2
dl 0
loc 36
ccs 9
cts 9
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A request() 0 15 2
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