Yelp::checkResponse()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 3

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 9
cts 9
cp 1
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 7
nc 2
nop 2
crap 3
1
<?php
2
3
namespace Stevenmaguire\OAuth2\Client\Provider;
4
5
use League\OAuth2\Client\Provider\AbstractProvider;
6
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
7
use Psr\Http\Message\ResponseInterface;
8
use Stevenmaguire\OAuth2\Client\Tool\ClientCredentialsOnlyTrait;
9
10
class Yelp extends AbstractProvider
11
{
12
    use ClientCredentialsOnlyTrait;
13
14
    /**
15
     * Get access token url to retrieve token
16
     *
17
     * @return string
18
     */
19 6
    public function getBaseAccessTokenUrl(array $params)
20
    {
21 6
        return 'https://api.yelp.com/oauth2/token';
22
    }
23
24
    /**
25
     * Check a provider response for errors.
26
     *
27
     * @throws IdentityProviderException
28
     * @param  ResponseInterface $response
29
     * @param  string $data Parsed response data
30
     * @return void
31
     */
32 4
    protected function checkResponse(ResponseInterface $response, $data)
33
    {
34 4
        $statusCode = $response->getStatusCode();
35 4
        if ($statusCode >= 400) {
36 2
            throw new IdentityProviderException(
37 2
                isset($data['error']['description']) ? $data['error']['description'] : $response->getReasonPhrase(),
38 1
                $statusCode,
39 1
                $response
0 ignored issues
show
Documentation introduced by
$response is of type object<Psr\Http\Message\ResponseInterface>, but the function expects a array|string.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
40 1
            );
41
        }
42 2
    }
43
}
44