Skip to content

Commit 3fa45c3

Browse files
committed
Move validation to Method class
1 parent 42d83de commit 3fa45c3

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

src/Client.php

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ public function api($endpoint, array $params = [], $method = Method::GET)
483483
{
484484
$headers = $this->getApiHeaders();
485485
$options = $this->prepareOptions($params, $method);
486-
$this->isMethodSupported($method);
486+
Method::isMethodSupported($method);
487487
if ($this->isUsingTokenParam()) {
488488
$params['oauth2_access_token'] = $this->accessToken->getToken();
489489
} else {
@@ -545,14 +545,4 @@ protected function prepareOptions(array $params, $method)
545545
}
546546
return $options;
547547
}
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-
}
558548
}

src/Http/Method.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,4 +66,14 @@ class Method extends AbstractEnum
6666
*
6767
*/
6868
const TRACE = 'TRACE';
69+
70+
/**
71+
* @param $method
72+
*/
73+
public static function isMethodSupported($method)
74+
{
75+
if (!in_array($method, [Method::GET, Method::POST])) {
76+
throw new \InvalidArgumentException('The method is not correct');
77+
}
78+
}
6979
}

0 commit comments

Comments
 (0)