| Total Complexity | 4 |
| Total Lines | 61 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 8 | abstract class AbstractEndpoint implements ExecutorInterface |
||
| 9 | { |
||
| 10 | /** |
||
| 11 | * Execution method. |
||
| 12 | */ |
||
| 13 | const REQUEST_METHOD = "GET"; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var FixerHttpClient |
||
| 17 | */ |
||
| 18 | protected $client; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | protected $path = ""; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * AbstractEndpoint constructor. |
||
| 27 | * |
||
| 28 | * @param FixerHttpClient $client |
||
| 29 | */ |
||
| 30 | public function __construct(FixerHttpClient $client) |
||
| 31 | { |
||
| 32 | $this->client = $client; |
||
| 33 | } |
||
| 34 | |||
| 35 | /** |
||
| 36 | * Builds the correct URI to perform requests. |
||
| 37 | * |
||
| 38 | * @param array $params |
||
| 39 | * |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public function buildURI(array $params = []): string |
||
| 43 | { |
||
| 44 | return join('?', [$this->path, $this->attachQueryParams($params)]); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** |
||
| 48 | * {@inheritdoc} |
||
| 49 | */ |
||
| 50 | public function execute() |
||
| 55 | ); |
||
| 56 | } |
||
| 57 | |||
| 58 | /** |
||
| 59 | * Attach query params to the request. |
||
| 60 | * |
||
| 61 | * @param array $params |
||
| 62 | * |
||
| 63 | * @return string |
||
| 64 | */ |
||
| 65 | private function attachQueryParams(array $params = []): string |
||
| 69 | ])); |
||
| 70 | } |
||
| 72 |