ApiError::responseError()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 4
dl 0
loc 3
rs 10
1
<?php
2
3
namespace DansMaCulotte\Newsletter\Exceptions;
4
5
use Exception;
6
use Throwable;
7
/**
8
 * Class ApiError
9
 * @package DansMaCulotte\Newsletter\Exceptions;
10
 */
11
class ApiError extends Exception
12
{
13
    /**
14
     * @param string $error
15
     * @param string $name
16
     * @param int $code
17
     * @param Throwable|null $previous
18
     * @return ApiError
19
     */
20
    public static function responseError(string $error, string $name, $code = 0, Throwable $previous = null)
21
    {
22
        return new static("{$name} returned an error: {$error}", $code, $previous);
23
    }
24
}
25