Passed
Push — main ( 46058f...95f3d8 )
by Breno
01:32
created

BelongsToField::belongsToField()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation;
5
6
trait BelongsToField
7
{
8
    private ?string $field = null;
9
10
    public function getField(): ?string
11
    {
12
        return $this->field;
13
    }
14
15
    public function withField(?string $field = null): static
16
    {
17
        $instance = clone $this;
18
        $instance->setField($field);
19
        return $instance;
20
    }
21
22
    protected function setField(?string $field): void
23
    {
24
        $this->field = $field;
25
    }
26
27
    public function belongsToField(): bool
28
    {
29
        return null !== $this->field;
30
    }
31
}
32