ApiException::translate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 7
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
1
<?php declare(strict_types=1);
2
3
namespace Audiens\AdForm\Exception;
4
5
/**
6
 * Exception thrown if API returns an error not handled by other exceptions
7
 */
8
class ApiException extends SeverityAwareException
9
{
10
    protected const MESSAGE = 'API returned an error: %s';
11
12
    public static function translate(string $message, int $code): self
13
    {
14
        return new self (
15
            sprintf(self::MESSAGE, $message),
16
            $code,
17
            null,
18
            SeverityAwareException::SEVERITY_ERROR
19
        );
20
    }
21
}
22