@@ -41,16 +41,14 @@ private function __construct(callable $getTokenRequestFunc)
4141 * @return Authentication
4242 */
4343 public static function createClientCredentials (
44- $ clientId ,
45- $ clientSecret ,
46- $ refreshResource = 'token ' ,
47- $ tokenResource = 'token '
44+ string $ clientId ,
45+ string $ clientSecret ,
46+ string $ refreshResource = 'token ' ,
47+ string $ tokenResource = 'token '
4848 ) : Authentication {
49- Util::throwIfNotType (['string ' => [$ clientId , $ clientSecret ]], true );
50-
5149 $ getTokenRequestFunc = function (
52- $ baseUrl ,
53- $ refreshToken
50+ string $ baseUrl ,
51+ string $ refreshToken = null
5452 ) use (
5553 $ clientId ,
5654 $ clientSecret ,
@@ -92,18 +90,16 @@ public static function createClientCredentials(
9290 * @return Authentication
9391 */
9492 public static function createOwnerCredentials (
95- $ clientId ,
96- $ clientSecret ,
97- $ username ,
98- $ password ,
99- $ refreshResource = 'token ' ,
100- $ tokenResource = 'token '
93+ string $ clientId ,
94+ string $ clientSecret ,
95+ string $ username ,
96+ string $ password ,
97+ string $ refreshResource = 'token ' ,
98+ string $ tokenResource = 'token '
10199 ) : Authentication {
102- Util::throwIfNotType (['string ' => [$ clientId , $ clientSecret , $ username , $ password ]], true );
103-
104100 $ getTokenRequestFunc = function (
105- $ baseUrl ,
106- $ refreshToken
101+ string $ baseUrl ,
102+ string $ refreshToken = null
107103 ) use (
108104 $ clientId ,
109105 $ clientSecret ,
@@ -166,16 +162,13 @@ public static function parseTokenResponse(ResponseInterface $response)
166162 /**
167163 * Creates a Request object for obtaining a new token from the API
168164 *
169- * @param string $baseUrl The base url of the API
170- * @param string $refreshToken The refresh token of the API
165+ * @param string $baseUrl The base url of the API
166+ * @param string|null $refreshToken The refresh token of the API
171167 *
172168 * @return RequestInterface
173169 */
174- public function getTokenRequest ($ baseUrl , $ refreshToken ) : RequestInterface
170+ public function getTokenRequest (string $ baseUrl , string $ refreshToken = null ) : RequestInterface
175171 {
176- Util::throwIfNotType (['string ' => [$ baseUrl ]], true );
177- Util::throwIfNotType (['string ' => [$ refreshToken ]], true , true );
178-
179172 return call_user_func ($ this ->getTokenRequestFunc , $ baseUrl , $ refreshToken );
180173 }
181174
@@ -192,11 +185,11 @@ public function getTokenRequest($baseUrl, $refreshToken) : RequestInterface
192185 * @return RequestInterface The built token refresh request
193186 */
194187 private static function getRefreshTokenRequest (
195- $ baseUrl ,
196- $ clientId ,
197- $ clientSecret ,
198- $ refreshResource ,
199- $ refreshToken
188+ string $ baseUrl ,
189+ string $ clientId ,
190+ string $ clientSecret ,
191+ string $ refreshResource ,
192+ string $ refreshToken
200193 ) : RequestInterface {
201194 //NOTE client_id and client_secret are needed for Apigee but are not in the oauth2 spec
202195 $ data = [
0 commit comments