Skip to content

Commit

Permalink
Remove magic methods aliases for send
Browse files Browse the repository at this point in the history
  • Loading branch information
slavcodev committed Aug 24, 2018
1 parent 3581e76 commit 23e8d4d
Showing 1 changed file with 30 additions and 29 deletions.
59 changes: 30 additions & 29 deletions src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,6 @@
* @see Client::createRequest()
* @see Client::createResponse()
*
* Magic facades for HTTP methods:
*
* @see Client::__call()
* @see Client::send()
*
* @method mixed get($path, $params = [], $headers = [])
* @method void head($path, $params = [], $headers = [])
* @method mixed post($payload, $path, $params = [], $headers = [])
* @method mixed put($payload, $path, $params = [], $headers = [])
* @method mixed patch($payload, $path, $params = [], $headers = [])
* @method void delete($path, $params = [], $headers = [])
*
* Magic methods for services factories:
*
* @see Client::__call()
Expand Down Expand Up @@ -100,9 +88,6 @@
* @method Services\GatewayAccountDowntimeService gatewayDowntimes()
* @method Services\PaymentInstrumentValidationService paymentInstrumentValidation()
* @method Services\KycService kycDocuments()
*
* @author Veaceslav Medvedev <veaceslav.medvedev@rebilly.com>
* @version 0.1
*/
final class Client
{
Expand Down Expand Up @@ -351,20 +336,6 @@ public function __invoke(Request $request, Response $response)
*/
public function __call($name, $arguments)
{
switch (strtoupper($name)) {
case 'HEAD':
case 'GET':
case 'DELETE':
array_unshift($arguments, null);
array_unshift($arguments, $name);
return call_user_func_array([$this, 'send'], $arguments);
case 'POST':
case 'PUT':
case 'PATCH':
array_unshift($arguments, $name);
return call_user_func_array([$this, 'send'], $arguments);
}

try {
return $this->service(lcfirst($name));
} catch (InvalidArgumentException $e) {
Expand Down Expand Up @@ -493,6 +464,36 @@ public function send($method, $payload, $path, $params = [], array $headers = []
return call_user_func($responseParsers[$contentType], $request, $response, $contentType);
}

public function head($path, $params = [], array $headers = [])
{
return $this->send('HEAD', null, $path, $params, $headers);
}

public function get($path, $params = [], array $headers = [])
{
return $this->send('GET', null, $path, $params, $headers);
}

public function post($payload, $path, $params = [], array $headers = [])
{
return $this->send('POST', $payload, $path, $params, $headers);
}

public function put($payload, $path, $params = [], array $headers = [])
{
return $this->send('PUT', $payload, $path, $params, $headers);
}

public function patch($payload, $path, $params = [], array $headers = [])
{
return $this->send('PATCH', $payload, $path, $params, $headers);
}

public function delete($path, $params = [], array $headers = [])
{
return $this->send('DELETE', null, $path, $params, $headers);
}

/**
* @param Request $request
* @param Response $response
Expand Down

0 comments on commit 23e8d4d

Please sign in to comment.