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

ObjectWithDynamicDataSet::getSource()   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
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\Tests\Support\Data;
6
7
use Yiisoft\Validator\DataSetInterface;
8
9
use function array_key_exists;
10
11
final class ObjectWithDynamicDataSet implements DataSetInterface
12
{
13
    public function __construct(private string $name)
14
    {
15
    }
16
17
    public function getAttributeValue(string $attribute): mixed
18
    {
19
        return $this->getData()[$attribute] ?? null;
20
    }
21
22
    public function getData(): ?array
23
    {
24
        return ['name' => $this->name];
25
    }
26
27
    public function getSource(): self
28
    {
29
        return $this;
30
    }
31
32
    public function hasAttribute(string $attribute): bool
33
    {
34
        return array_key_exists($attribute, $this->getData());
35
    }
36
}
37