Passed
Push — main ( 93c199...f7f95e )
by Breno
01:50
created

Required   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 7
Duplicated Lines 0 %

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A isValid() 0 4 2
1
<?php
2
declare(strict_types=1);
3
4
namespace BrenoRoosevelt\Validation\Rules;
5
6
use Attribute;
7
use BrenoRoosevelt\Validation\AbstractRule;
8
9
#[Attribute(Attribute::TARGET_PROPERTY)]
10
final class Required extends AbstractRule
11
{
12
    public function isValid(mixed $input, array $context = []): bool
13
    {
14
        $field = $this->getField();
15
        return null !== $field && array_key_exists($field, $context);
16
    }
17
}
18