SePayIdentityProviderException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 8
c 3
b 0
f 0
dl 0
loc 21
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A fromResponse() 0 3 1
A oauthException() 0 5 1
A clientException() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Datlechin\OAuth2\Client\Provider\Exception;
6
7
use League\OAuth2\Client\Provider\Exception\IdentityProviderException;
8
use Psr\Http\Message\ResponseInterface;
9
10
class SePayIdentityProviderException extends IdentityProviderException
11
{
12
    public static function clientException(ResponseInterface $response, $data): self
13
    {
14
        return static::fromResponse(
15
            $response,
16
            $data['message'] ?? $response->getReasonPhrase()
17
        );
18
    }
19
20
    public static function oauthException(ResponseInterface $response, $data): self
21
    {
22
        return static::fromResponse(
23
            $response,
24
            $data['error'] ?? $response->getReasonPhrase()
25
        );
26
    }
27
28
    protected static function fromResponse(ResponseInterface $response, $message = null): self
29
    {
30
        return new static($message, $response->getStatusCode(), (string) $response->getBody());
31
    }
32
}
33