GithubIdentityProviderException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 47
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

3 Methods

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