Passed
Push — master ( 5c8f34...432941 )
by Mr
01:54
created

ValidatorDefinition::getName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php declare(strict_types=1);
2
/**
3
 * This file is part of the daikon-cqrs/validize project.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
9
namespace Daikon\Validize\Validation;
10
11
use Daikon\Validize\ValueObject\Severity;
12
13
final class ValidatorDefinition
14
{
15
    private string $name;
16
17
    private Severity $severity;
18
19
    private array $settings;
20
21
    /** @var mixed */
22
    private $argument;
23
24
    private array $imports = [];
25
26
    public function __construct(string $name, Severity $severity, array $settings = [])
27
    {
28
        $this->name = $name;
29
        $this->severity = $severity;
30
        $this->settings = $settings;
31
    }
32
33
    public function getName(): string
34
    {
35
        return $this->name;
36
    }
37
38
    public function getSeverity(): Severity
39
    {
40
        return $this->severity;
41
    }
42
43
    public function getSettings(): array
44
    {
45
        return $this->settings;
46
    }
47
48
    /** @return mixed */
49
    public function getArgument()
50
    {
51
        return $this->argument;
52
    }
53
54
    /** @param mixed $argument */
55
    public function withArgument($argument): self
56
    {
57
        $copy = clone $this;
58
        $copy->argument = is_object($argument) ? clone $argument : $argument;
59
        return $copy;
60
    }
61
62
    public function getImports(): array
63
    {
64
        return $this->imports;
65
    }
66
67
    /** @param mixed $import */
68
    public function withImport(string $name, $import): self
69
    {
70
        $copy = clone $this;
71
        $copy->imports[$name] = is_object($import) ? clone $import : $import;
72
        return $copy;
73
    }
74
}
75