Rule::getMessage()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 1
cts 1
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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