Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
ImportException | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
4 | |
100.00% |
1 / 1 |
__construct | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
4 |
1 | <?php |
2 | |
3 | namespace FileImporter\Exceptions; |
4 | |
5 | use RuntimeException; |
6 | use Throwable; |
7 | |
8 | /** |
9 | * @license GPL-2.0-or-later |
10 | * @author Addshore |
11 | */ |
12 | class ImportException extends RuntimeException { |
13 | |
14 | /** |
15 | * @param string $message |
16 | * @param int|string $code |
17 | * @param Throwable|null $previous |
18 | */ |
19 | public function __construct( string $message, $code, ?Throwable $previous = null ) { |
20 | if ( is_string( $code ) && ctype_digit( $code ) ) { |
21 | $code = (int)$code; |
22 | } |
23 | |
24 | parent::__construct( $message, (int)$code, $previous ); |
25 | |
26 | // Not all codes can be passed through the constructor due to type hints |
27 | if ( !is_int( $code ) ) { |
28 | $this->code = $code; |
29 | } |
30 | } |
31 | |
32 | } |