Passed
Push — master ( 74010f...cd30de )
by Tom
03:00
created

StatusException::__construct()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 4
eloc 5
nc 2
nop 3
dl 0
loc 10
ccs 6
cts 6
cp 1
crap 4
rs 10
c 2
b 1
f 0
1
<?php
2
3
/* this file is part of pipelines */
4
5
namespace Ktomk\Pipelines\Utility;
6
7
use Exception;
8
9
/**
10
 * Signal utility exit status, optionally with an (error) message
11
 */
12
class StatusException extends Exception
13
{
14
    /**
15
     * StatusException constructor.
16
     *
17
     * @param string $message
18
     * @param int|string $code
19
     * @param null|Exception $previous
20
     */
21 6
    public function __construct($message = '', $code = 0, Exception $previous = null)
22
    {
23 6
        if (!is_int($code) || $code < 0 || $code > 255) {
24 2
            throw new \InvalidArgumentException(sprintf(
25 2
                'Code must be integer in range from 0 to 255, %s given',
26 2
                var_export($code, true)
27
            ));
28
        }
29
30 4
        parent::__construct($message, $code, $previous);
31 4
    }
32
}
33