Passed
Push — master ( b0f622...44cfae )
by Magnar Ovedal
02:42
created

RuleException::getRule()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
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 Symfony\Component\Translation\Translator;
10
use Throwable;
11
12
/**
13
 * Exception thrown when a rule could not be enforced.
14
 */
15
class RuleException extends RuntimeException
16
{
17
    /**
18
     * @var Rule Rule that could not be enforced.
19
     */
20
    private $rule;
21
22
    /**
23
     * @param Rule $rule Rule that could not be enforced.
24
     * @param string $message Exception message.
25
     * @param Throwable $previous Previous exception, used for exception chaining.
26
     */
27 1
    public function __construct(Rule $rule, string $message, ?Throwable $previous = null)
28
    {
29 1
        $this->rule = $rule;
30
31 1
        parent::__construct($message, /*code*/0, $previous);
32 1
    }
33
34 1
    public function getRule(): Rule
35
    {
36 1
        return $this->rule;
37
    }
38
}
39