Passed
Push — main ( b4697e...9f091b )
by Breno
01:42
created

AnError   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A rule() 0 3 1
A message() 0 3 1
A field() 0 3 1
A __construct() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation;
5
6
use BrenoRoosevelt\Validation\Contracts\Error;
7
use BrenoRoosevelt\Validation\Contracts\Rule;
8
9
final class AnError implements Error
10
{
11
    public function __construct(
12
        private string $message,
13
        private ?string $field = null,
14
        private ?Rule $rule = null
15
    ) {
16
    }
17
18
    /** @inheritDoc */
19
    public function message(): string
20
    {
21
        return $this->message;
22
    }
23
24
    /** @inheritDoc */
25
    public function field(): ?string
26
    {
27
        return $this->field;
28
    }
29
30
    /** @inheritDoc */
31
    public function rule(): ?Rule
32
    {
33
        return $this->rule;
34
    }
35
}
36