Completed
Push — master ( c9c239...8e345a )
by Alex
03:10
created

StackExchangeException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
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 16
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
declare(strict_types=1);
3
4
namespace AlexMasterov\OAuth2\Client\Provider;
5
6
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
7
use Psr\Http\Message\ResponseInterface;
8
9
class StackExchangeException extends IdentityProviderException
10
{
11 1
    public static function errorResponse(ResponseInterface $response, array $data): StackExchangeException
12
    {
13 1
        $message = $data['error']['type'];
14
15 1
        if (!empty($data['error']['message'])) {
16 1
            $message .= ': ' . $data['error']['message'];
17
        }
18
19 1
        $code = $response->getStatusCode();
20 1
        $body = (string) $response->getBody();
21
22 1
        return new static($message, $code, $body);
23
    }
24
}
25