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