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

ValidatorDefinition   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 20
c 0
b 0
f 0
dl 0
loc 60
ccs 0
cts 37
cp 0
rs 10
wmc 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A withArgument() 0 5 2
A getImports() 0 3 1
A __construct() 0 5 1
A withImport() 0 5 2
A getSeverity() 0 3 1
A getSettings() 0 3 1
A getName() 0 3 1
A getArgument() 0 3 1
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