GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

PaddleApiException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 28
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A unsuccessfulStatus() 0 4 1
A fromResponse() 0 8 2
1
<?php
2
3
namespace ProtoneMedia\LaravelPaddle\Api;
4
5
class PaddleApiException extends \Exception
6
{
7
    /**
8
     * Creates an instance for an unsuccesful request
9
     *
10
     * @param  int    $status
11
     * @return $this
12
     */
13
    public static function unsuccessfulStatus(int $status)
14
    {
15
        return new static("Response with status code {$status}");
16
    }
17
18
    /**
19
     * Creates an instance for a response that contains an error
20
     *
21
     * @param  array    $response
22
     * @return $this
23
     */
24
    public static function fromResponse(array $response)
25
    {
26
        if (array_key_exists('error', $response)) {
27
            return new static("[{$response['error']['code']}] {$response['error']['message']}");
28
        }
29
30
        return new static("Paddle API request was unsuccessful and no error code/message was returned");
31
    }
32
}
33