for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace AcquiroPay;
trait MakesHttpRequests
{
/** @var Api */
public $api;
/** @var string */
public $serviceName;
/**
* @param string $method
* @param string $uri
* @param array $parameters
* @return array
*/
public function callService(string $method, string $uri, array $parameters = null): array
$data = json_decode(json_encode($this->api->callService($this->serviceName, $method, $uri, $parameters)), true);
if (!is_array($data)) {
// todo throw error?
return [];
}
return $data;
*
* @param array|null $parameters
* @return mixed
protected function get(string $uri, array $parameters = null): array
return $this->callService('GET', $uri, $parameters);
protected function post(string $uri, array $parameters = null): array
return $this->callService('POST', $uri, $parameters);
protected function put(string $uri, array $parameters = null): array
return $this->callService('PUT', $uri, $parameters);
protected function delete(string $uri, array $parameters = null): array
return $this->callService('DELETE', $uri, $parameters);