InstagramIdentityProviderException   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 50
ccs 18
cts 18
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A clientException() 0 15 3
A oauthException() 0 15 3
1
<?php
2
3
namespace League\OAuth2\Client\Provider\Exception;
4
5
use Psr\Http\Message\ResponseInterface;
6
7
class InstagramIdentityProviderException extends IdentityProviderException
8
{
9
    /**
10
     * Creates client exception from response.
11
     *
12
     * @param  ResponseInterface $response
13
     * @param  string $data Parsed response data
14
     *
15
     * @return IdentityProviderException
16
     */
17 2
    public static function clientException(ResponseInterface $response, $data)
18
    {
19 2
        $message = $response->getReasonPhrase();
20 2
        $code = $response->getStatusCode();
21 2
        $body = (string) $response->getBody();
22
23 2
        if (isset($data['error'], $data['error']['message'])) {
24 2
            $message = $data['error']['message'];
25
        }
26 2
        if (isset($data['error'], $data['error']['code'])) {
27 2
            $code = $data['error']['code'];
28
        }
29
30 2
        return new static($message, $code, $body);
31
    }
32
33
    /**
34
     * Creates oauth exception from response.
35
     *
36
     * @param  ResponseInterface $response
37
     * @param  string $data Parsed response data
38
     *
39
     * @return IdentityProviderException
40
     */
41 2
    public static function oauthException(ResponseInterface $response, $data)
42
    {
43 2
        $message = $response->getReasonPhrase();
44 2
        $code = $response->getStatusCode();
45 2
        $body = (string) $response->getBody();
46
47 2
        if (isset($data['error_message'])) {
48 2
            $message = $data['error_message'];
49
        }
50 2
        if (isset($data['code'])) {
51 2
            $code = $data['code'];
52
        }
53
54 2
        return new static($message, $code, $body);
55
    }
56
}
57