JiraIdentityProviderException   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 45
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A oauthException() 0 5 2
A clientException() 0 5 2
A fromResponse() 0 3 1
1
<?php
2
3
namespace Mrjoops\OAuth2\Client\Provider\Exception;
4
5
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
6
use Psr\Http\Message\ResponseInterface;
7
8
class JiraIdentityProviderException extends IdentityProviderException
9
{
10
    /**
11
     * Creates client exception from response.
12
     *
13
     * @param  ResponseInterface $response
14
     * @param  array $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 3
            $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  array $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 3
            $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