Completed
Push — master ( d234f3...0a4926 )
by Jan Philipp
47s queued 12s
created

ExitSignal::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Psh\Application;
4
5
use RuntimeException;
6
use Throwable;
7
8
class ExitSignal extends RuntimeException
9
{
10
    public const RESULT_SUCCESS = 0;
11
12
    public const RESULT_ERROR = 1;
13
14
    /**
15
     * @var int
16
     */
17
    private $signal;
18
19
    public static function success(): self
20
    {
21
        return new self(self::RESULT_SUCCESS);
22
    }
23
24
    public static function error(): self
25
    {
26
        return new self(self::RESULT_ERROR);
27
    }
28
29
    public function __construct(int $signal, $message = '', $code = 0, ?Throwable $previous = null)
30
    {
31
        parent::__construct($message, $code, $previous);
32
        $this->signal = $signal;
33
    }
34
35
    public function signal(): int
36
    {
37
        return $this->signal;
38
    }
39
}
40