Rule   A
last analyzed

Complexity

Total Complexity 11

Size/Duplication

Total Lines 106
Duplicated Lines 0 %

Test Coverage

Coverage 52.94%

Importance

Changes 0
Metric Value
wmc 11
eloc 16
dl 0
loc 106
ccs 9
cts 17
cp 0.5294
rs 10
c 0
b 0
f 0

11 Methods

Rating   Name   Duplication   Size   Complexity  
A setMessage() 0 4 1
A getExpression() 0 3 1
A setField() 0 4 1
A getField() 0 3 1
A setCode() 0 4 1
A __construct() 0 8 1
A getCode() 0 3 1
A getArgument() 0 3 1
A getMessage() 0 3 1
A setExpression() 0 4 1
A setArgument() 0 4 1
1
<?php
2
3
namespace kalanis\Restful\Validation;
4
5
6
/**
7
 * Validation Rule caret
8
 * @package kalanis\Restful\Validation
9
 */
10
class Rule
11
{
12
13
    /**
14
     * @param string $field
15
     * @param string $message
16
     * @param int $code
17
     * @param string $expression
18
     * @param array<bool|float|int|string|null> $argument
19
     */
20 1
    public function __construct(
21
        public string $field = '',
22
        public string $message = '',
23
        public int    $code = 0,
24
        public string $expression = '',
25
        public array  $argument = [],
26
    )
27
    {
28 1
    }
29
30
    /**
31
     * Get rule error code
32
     * @return int
33
     */
34
    public function getCode(): int
35
    {
36 1
        return $this->code;
37
    }
38
39
    /**
40
     * Set rule error code
41
     */
42
    public function setCode(int $code): static
43
    {
44
        $this->code = $code;
45
        return $this;
46
    }
47
48
    /**
49
     * Get field name
50
     */
51
    public function getField(): string
52
    {
53 1
        return $this->field;
54
    }
55
56
    /**
57
     * Set field name
58
     */
59
    public function setField(string $field): self
60
    {
61
        $this->field = $field;
62
        return $this;
63
    }
64
65
    /**
66
     * Get rule error message
67
     */
68
    public function getMessage(): string
69
    {
70 1
        return $this->message;
71
    }
72
73
    /**
74
     * Set rule error message
75
     */
76
    public function setMessage(string $message): static
77
    {
78 1
        $this->message = $message;
79 1
        return $this;
80
    }
81
82
    /**
83
     * Get rule expression
84
     */
85
    public function getExpression(): string
86
    {
87 1
        return $this->expression;
88
    }
89
90
    /**
91
     * Set rule expression
92
     */
93
    public function setExpression(string $expression): static
94
    {
95
        $this->expression = $expression;
96
        return $this;
97
    }
98
99
    /**
100
     * Get rule arguments
101
     * @return array<bool|float|int|string|null>
102
     */
103
    public function getArgument(): array
104
    {
105 1
        return $this->argument;
106
    }
107
108
    /**
109
     * Set rule argument(s)
110
     * @param array<bool|float|int|string|null> $argument
111
     */
112
    public function setArgument(array $argument): static
113
    {
114
        $this->argument = $argument;
115
        return $this;
116
    }
117
}
118