1 | <?php |
||
15 | class NativeHttpClient implements HttpClientInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var \Marek\Toggable\Http\Converter\ArgumentsConverterInterface |
||
19 | */ |
||
20 | private $converter; |
||
21 | |||
22 | /** |
||
23 | * @var \Marek\Toggable\Http\Parser\HttpResponseParserInterface |
||
24 | */ |
||
25 | private $parser; |
||
26 | |||
27 | /** |
||
28 | * @var |
||
29 | */ |
||
30 | private $uri; |
||
31 | |||
32 | /** |
||
33 | * @var \Marek\Toggable\API\Security\TokenInterface |
||
34 | */ |
||
35 | private $token; |
||
36 | |||
37 | /** |
||
38 | * @var array |
||
39 | */ |
||
40 | private $data; |
||
41 | |||
42 | /** |
||
43 | * NativeHttpClient constructor. |
||
44 | * |
||
45 | * @param string $uri |
||
46 | * @param \Marek\Toggable\API\Security\TokenInterface $token |
||
47 | * @param \Marek\Toggable\Http\Converter\ArgumentsConverterInterface $converter |
||
48 | * @param \Marek\Toggable\Http\Parser\HttpResponseParserInterface $parser |
||
49 | * |
||
50 | * @throws \InvalidArgumentException |
||
51 | */ |
||
52 | 18 | public function __construct($uri, TokenInterface $token, ArgumentsConverterInterface $converter, HttpResponseParserInterface $parser) |
|
53 | { |
||
54 | 18 | $this->converter = $converter; |
|
55 | 18 | $this->parser = $parser; |
|
56 | |||
57 | 18 | if (empty($uri) || !is_string($uri) || filter_var($uri, FILTER_VALIDATE_URL) === false) { |
|
58 | 1 | throw new InvalidArgumentException( |
|
59 | 1 | sprintf('Please provide valid ur in %s', get_class($this)) |
|
60 | ); |
||
61 | } |
||
62 | 17 | $this->uri = $uri; |
|
63 | 17 | $this->token = $token; |
|
64 | 17 | } |
|
65 | |||
66 | /** |
||
67 | * @inheritDoc |
||
68 | */ |
||
69 | public function send() |
||
91 | |||
92 | /** |
||
93 | * @inheritDoc |
||
94 | */ |
||
95 | 1 | public function prepare(\Marek\Toggable\API\Http\Request\RequestInterface $request) |
|
99 | |||
100 | /** |
||
101 | * @inheritDoc |
||
102 | */ |
||
103 | 1 | public function getResponse() |
|
109 | } |
||
110 |