Completed
Push — master ( c67749...e01f26 )
by Alex
01:55
created

StackExchangeException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A errorResponse() 0 13 2
1
<?php
2
3
namespace AlexMasterov\OAuth2\Client\Provider\Exception;
4
5
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
6
use Psr\Http\Message\ResponseInterface;
7
8
class StackExchangeException extends IdentityProviderException
9
{
10
    /**
11
     * @param ResponseInterface $response
12
     * @param string|array $data
13
     *
14
     * @return static
15
     */
16 1
    public static function errorResponse(ResponseInterface $response, $data)
17
    {
18 1
        $message = $data['error']['type'];
19
20 1
        if (!empty($data['error']['message'])) {
21 1
            $message .= ': '.$data['error']['message'];
22
        }
23
24 1
        $code = $response->getStatusCode();
25 1
        $body = (string) $response->getBody();
26
27 1
        return new static($message, $code, $body);
28
    }
29
}
30