CouldNotUseRuleException   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 25
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getRule() 0 3 1
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