Skip to content

Commit 42d83de

Browse files
committed
Take validation out
1 parent db52956 commit 42d83de

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/Client.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -483,9 +483,7 @@ public function api($endpoint, array $params = [], $method = Method::GET)
483483
{
484484
$headers = $this->getApiHeaders();
485485
$options = $this->prepareOptions($params, $method);
486-
if (!in_array($method, [Method::GET, Method::POST])) {
487-
throw new \InvalidArgumentException('The method is not correct');
488-
}
486+
$this->isMethodSupported($method);
489487
if ($this->isUsingTokenParam()) {
490488
$params['oauth2_access_token'] = $this->accessToken->getToken();
491489
} else {
@@ -536,7 +534,7 @@ public function post($endpoint, array $params = [])
536534

537535
/**
538536
* @param array $params
539-
* @param $method
537+
* @param string $method
540538
* @return mixed
541539
*/
542540
protected function prepareOptions(array $params, $method)
@@ -547,4 +545,14 @@ protected function prepareOptions(array $params, $method)
547545
}
548546
return $options;
549547
}
548+
549+
/**
550+
* @param $method
551+
*/
552+
private function isMethodSupported($method)
553+
{
554+
if (!in_array($method, [Method::GET, Method::POST])) {
555+
throw new \InvalidArgumentException('The method is not correct');
556+
}
557+
}
550558
}

0 commit comments

Comments
 (0)