1414abstract class AbstractApi
1515{
1616 /**
17- * @var \Imgur\ Client
17+ * @var Client
1818 */
1919 protected $ client ;
2020
2121 /**
22- * @var \Imgur\Pager\ PagerInterface
22+ * @var PagerInterface
2323 */
2424 protected $ pager ;
2525
@@ -31,16 +31,12 @@ public function __construct(Client $client, PagerInterface $pager = null)
3131
3232 /**
3333 * Perform a GET request and return the parsed response.
34- *
35- * @param string $url
36- *
37- * @return array
3834 */
39- public function get ($ url , $ parameters = [])
35+ public function get (string $ url , array $ parameters = []): array
4036 {
4137 $ httpClient = $ this ->client ->getHttpClient ();
4238
43- if (! empty ( $ this ->pager ) ) {
39+ if (null !== $ this ->pager ) {
4440 $ parameters ['page ' ] = $ this ->pager ->getPage ();
4541 $ parameters ['perPage ' ] = $ this ->pager ->getResultsPerPage ();
4642 }
@@ -52,12 +48,8 @@ public function get($url, $parameters = [])
5248
5349 /**
5450 * Perform a POST request and return the parsed response.
55- *
56- * @param string $url
57- *
58- * @return array
5951 */
60- public function post ($ url , $ parameters = [])
52+ public function post (string $ url , array $ parameters = []): array
6153 {
6254 $ httpClient = $ this ->client ->getHttpClient ();
6355
@@ -68,12 +60,8 @@ public function post($url, $parameters = [])
6860
6961 /**
7062 * Perform a PUT request and return the parsed response.
71- *
72- * @param string $url
73- *
74- * @return array
7563 */
76- public function put ($ url , $ parameters = [])
64+ public function put (string $ url , array $ parameters = []): array
7765 {
7866 $ httpClient = $ this ->client ->getHttpClient ();
7967
@@ -84,12 +72,8 @@ public function put($url, $parameters = [])
8472
8573 /**
8674 * Perform a DELETE request and return the parsed response.
87- *
88- * @param string $url
89- *
90- * @return array
9175 */
92- public function delete ($ url , $ parameters = [])
76+ public function delete (string $ url , array $ parameters = []): array
9377 {
9478 $ httpClient = $ this ->client ->getHttpClient ();
9579
@@ -101,32 +85,29 @@ public function delete($url, $parameters = [])
10185 /**
10286 * Validate "sort" parameter and throw an exception if it's a bad value.
10387 *
104- * @param string $sort Input value
105- * @param array $possibleValues
88+ * @param string $sort Input value
10689 */
107- protected function validateSortArgument ($ sort , $ possibleValues )
90+ protected function validateSortArgument (string $ sort , array $ possibleValues ): void
10891 {
10992 $ this ->validateArgument ('Sort ' , $ sort , $ possibleValues );
11093 }
11194
11295 /**
11396 * Validate "window" parameter and throw an exception if it's a bad value.
11497 *
115- * @param string $window Input value
116- * @param array $possibleValues
98+ * @param string $window Input value
11799 */
118- protected function validateWindowArgument ($ window , $ possibleValues )
100+ protected function validateWindowArgument (string $ window , array $ possibleValues ): void
119101 {
120102 $ this ->validateArgument ('Window ' , $ window , $ possibleValues );
121103 }
122104
123105 /**
124106 * Validate "vote" parameter and throw an exception if it's a bad value.
125107 *
126- * @param string $vote Input value
127- * @param array $possibleValues
108+ * @param string $vote Input value
128109 */
129- protected function validateVoteArgument ($ vote , $ possibleValues )
110+ protected function validateVoteArgument (string $ vote , array $ possibleValues ): void
130111 {
131112 $ this ->validateArgument ('Vote ' , $ vote , $ possibleValues );
132113 }
@@ -138,7 +119,7 @@ protected function validateVoteArgument($vote, $possibleValues)
138119 * @param string $input Input value
139120 * @param array $possibleValues Possible values for this argument
140121 */
141- private function validateArgument ($ type , $ input , $ possibleValues )
122+ private function validateArgument (string $ type , string $ input , array $ possibleValues ): void
142123 {
143124 if (!\in_array ($ input , $ possibleValues , true )) {
144125 throw new InvalidArgumentException ($ type . ' parameter " ' . $ input . '" is wrong. Possible values are: ' . implode (', ' , $ possibleValues ));
0 commit comments