CouldNotUseRuleException::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Stadly\PasswordPolice\Rule;
6
7
use RuntimeException;
8
use Stadly\PasswordPolice\Rule;
9
use Throwable;
10
11
/**
12
 * Exception thrown if a rule caused an error.
13
 */
14
final class CouldNotUseRuleException extends RuntimeException
15
{
16
    /**
17
     * @var Rule Rule that caused the error.
18
     */
19
    private $rule;
20
21
    /**
22
     * @param Rule $rule Rule that caused the error.
23
     * @param string $message Exception message.
24
     * @param Throwable|null $previous Previous exception, used for exception chaining.
25
     */
26 1
    public function __construct(Rule $rule, string $message, ?Throwable $previous = null)
27
    {
28 1
        $this->rule = $rule;
29
30 1
        parent::__construct($message, /*code*/0, $previous);
31 1
    }
32
33
    /**
34
     * @return Rule Rule that caused the error.
35
     */
36 1
    public function getRule(): Rule
37
    {
38 1
        return $this->rule;
39
    }
40
}
41