1 | <?php |
||
2 | |||
3 | namespace bSecure; |
||
4 | |||
5 | use bSecure\Helpers\Constant; |
||
6 | |||
7 | abstract class OAuth |
||
8 | { |
||
9 | |||
10 | // Self-referential 'abstract' declaration |
||
11 | const GRANT_TYPE = Constant::AUTH_GRANT_TYPE; |
||
12 | |||
13 | /** |
||
14 | * Generate authorization credentials to connect your builder's account to your platform and |
||
15 | * fetch the record from bSecure. |
||
16 | * |
||
17 | * @param array $params |
||
18 | * |
||
19 | * @throws \bSecure\ApiResponse if the request fails |
||
20 | * |
||
21 | * @return OAuthObject object containing your authorization credentials |
||
0 ignored issues
–
show
|
|||
22 | */ |
||
23 | public static function token() |
||
24 | { |
||
25 | $credentials = self::verifyAppCredentials(); |
||
26 | |||
27 | $requestor = new ApiRequest(); |
||
28 | $response = $requestor->request( |
||
29 | 'post', |
||
30 | Constant::API_ENDPOINTS['oauth'], |
||
31 | $credentials, |
||
32 | Constant::NO |
||
33 | ); |
||
34 | return $response[0]; |
||
0 ignored issues
–
show
|
|||
35 | } |
||
36 | |||
37 | private static function _getClientId() |
||
38 | { |
||
39 | $APP_INFO = bSecure::getAppInfo(); |
||
40 | |||
41 | $clientId = ($APP_INFO && \array_key_exists('client_id', $APP_INFO)) ? $APP_INFO['client_id'] : null; |
||
0 ignored issues
–
show
The expression
$APP_INFO of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
42 | if (null === $clientId) { |
||
43 | $clientId = bSecure::getClientId(); |
||
44 | } |
||
45 | if (null === $clientId) { |
||
46 | $msg = 'No client_id provided. (HINT: set your client_id using ' |
||
47 | . '"bSecure::setClientId(<CLIENT-ID>)". You can find your client_ids ' |
||
48 | . 'in your bSecure Builder\'s dashboard at ' |
||
49 | . Constant::BUILDERS_DASHBOARD_LINK.', ' |
||
50 | . 'after registering your account as a platform. See ' |
||
51 | . '.Constant::SUPPORT_EMAIL.'.' for details, ' |
||
52 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
||
53 | throw new Exception\AuthenticationException($msg); |
||
54 | } |
||
55 | |||
56 | return $clientId; |
||
57 | } |
||
58 | |||
59 | private static function _getClientSecret() |
||
60 | { |
||
61 | $APP_INFO = bSecure::getAppInfo(); |
||
62 | |||
63 | $clientSecret = ($APP_INFO && \array_key_exists('client_secret', $APP_INFO)) ? $APP_INFO['client_secret'] : null; |
||
0 ignored issues
–
show
The expression
$APP_INFO of type array is implicitly converted to a boolean; are you sure this is intended? If so, consider using ! empty($expr) instead to make it clear that you intend to check for an array without elements.
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent. Consider making the comparison explicit by using ![]() |
|||
64 | |||
65 | if (null === $clientSecret) { |
||
66 | $clientSecret = bSecure::getClientSecret(); |
||
67 | } |
||
68 | if (null === $clientSecret) { |
||
69 | $msg = 'No client_secret provided. (HINT: set your client_secret using ' |
||
70 | . '"bSecure::setClientSecret(<CLIENT-SECRET>)". You can find your client_secrets ' |
||
71 | . 'in your bSecure Builder\'s dashboard at ' |
||
72 | . Constant::BUILDERS_DASHBOARD_LINK.', ' |
||
73 | . 'after registering your account as a platform. See ' |
||
74 | . Constant::INTEGRATION_TAB_LINK.','.' for details, ' |
||
75 | . 'or email '.Constant::SUPPORT_EMAIL.' if you have any questions.'; |
||
76 | |||
77 | throw new Exception\AuthenticationException($msg); |
||
78 | } |
||
79 | |||
80 | return $clientSecret; |
||
81 | } |
||
82 | |||
83 | private static function verifyAppCredentials() |
||
84 | { |
||
85 | return [ |
||
86 | "grant_type"=> self::GRANT_TYPE, |
||
87 | 'client_id' => self::_getClientId(), |
||
88 | 'client_secret' => self::_getClientSecret(), |
||
89 | ]; |
||
90 | } |
||
91 | } |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths