1 | <?php |
||
28 | class ResourceBasedClient |
||
29 | { |
||
30 | /** |
||
31 | * @var HttpClientInterface |
||
32 | */ |
||
33 | protected $client; |
||
34 | |||
35 | /** |
||
36 | * @var RouteRepository |
||
37 | */ |
||
38 | protected $repository; |
||
39 | |||
40 | /** |
||
41 | * ResourceBasedClient constructor. |
||
42 | * |
||
43 | * @param HttpClientInterface $client |
||
44 | * @param RouteRepository $repository |
||
45 | */ |
||
46 | 7 | public function __construct(HttpClientInterface $client, RouteRepository $repository) |
|
51 | |||
52 | /** |
||
53 | * Send a request |
||
54 | * |
||
55 | * @param string $method |
||
56 | * @param string $resource |
||
57 | * @param array $parameters |
||
58 | * @param array $headers |
||
59 | * @param mixed $body |
||
60 | * |
||
61 | * @return ResponseInterface |
||
62 | */ |
||
63 | 5 | public function request(string $method, string $resource, array $parameters = [], array $headers = [], $body = null): ResponseInterface |
|
73 | |||
74 | /** |
||
75 | * Send a request using name of method as an HTTP-method |
||
76 | * |
||
77 | * $client->get('user', ['id' => 1]) |
||
78 | * is equal to: |
||
79 | * $client->request('GET', 'user', ['id' => 1]) |
||
80 | * |
||
81 | * @param string $name |
||
82 | * @param array $arguments |
||
83 | * @return ResponseInterface |
||
84 | */ |
||
85 | 3 | public function __call(string $name, array $arguments): ResponseInterface |
|
91 | } |