Passed
Pull Request — master (#464)
by Sergei
11:05
created

RulesProvidedDataSet::getAttributeValue()   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 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Support\DataSet;
6
7
use Yiisoft\Validator\DataSetInterface;
8
use Yiisoft\Validator\RulesProviderInterface;
9
10
use function array_key_exists;
11
12
final class RulesProvidedDataSet implements RulesProviderInterface, DataSetInterface
13
{
14
    public function __construct(private array $data, private array $rules)
15
    {
16
    }
17
18
    public function getAttributeValue(string $attribute): mixed
19
    {
20
        return $this->data[$attribute] ?? null;
21
    }
22
23
    public function getRules(): iterable
24
    {
25
        return $this->rules;
26
    }
27
28
    public function getData(): ?array
29
    {
30
        return $this->data;
31
    }
32
33
    public function getSource(): array
34
    {
35
        return $this->data;
36
    }
37
38
    public function hasAttribute(string $attribute): bool
39
    {
40
        return array_key_exists($attribute, $this->data);
41
    }
42
}
43