Completed
Push — master ( c91a90...e32b70 )
by Chris
02:54
created

Exception   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 44.44%

Importance

Changes 0
Metric Value
wmc 4
eloc 9
dl 0
loc 25
ccs 4
cts 9
cp 0.4444
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 13 3
A withMessage() 0 3 1
1
<?php declare(strict_types=1);
2
3
namespace DaveRandom\Jom\Exceptions;
4
5
abstract class Exception extends \Exception
6
{
7 73
    /**
8
     * @param string $format
9 73
     * @param mixed ...$args
10
     * @return static
11
     */
12
    public static function withMessage(string $format, ...$args): self
13 73
    {
14
        return new static(\vsprintf($format, $args));
15
    }
16
17
    public function __construct($message, $code = 0, \Throwable $previous = null)
18 73
    {
19
        if ($message instanceof \Throwable) {
20
            parent::__construct($message->getMessage(), $message->getCode(), $message);
21
            return;
22
        }
23
24
        if ($code instanceof \Throwable) {
25
            parent::__construct((string)$message, $code->getCode(), $code);
26
            return;
27
        }
28
29
        parent::__construct((string)$message, (int)$code, $previous);
30
    }
31
}
32