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

Required::isValid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 2
dl 0
loc 4
rs 10
c 1
b 1
f 0
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