Passed
Push — main ( f7f95e...c4cb1e )
by Breno
02:19
created

BelongsToFieldTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 19
rs 10
c 2
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A belongsToField() 0 3 1
A getField() 0 3 1
A setField() 0 5 1
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation;
5
6
trait BelongsToFieldTrait
7
{
8
    private ?string $field = null;
9
10
    public function getField(): ?string
11
    {
12
        return $this->field;
13
    }
14
15
    public function setField(?string $field = null): static
16
    {
17
        $instance = clone $this;
18
        $instance->field = $field;
19
        return $instance;
20
    }
21
22
    public function belongsToField(): bool
23
    {
24
        return $this->field !== null;
25
    }
26
}
27