Passed
Pull Request — master (#322)
by
unknown
02:36
created

MixedDataSet::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Validator\DataSet;
6
7
use Yiisoft\Validator\DataSetInterface;
8
9
/**
10
 * Used for a single value of any (mixed) data type. Does not support attributes.
11
 */
12
final class MixedDataSet implements DataSetInterface
13
{
14
    private mixed $value;
15
16 40
    public function __construct(mixed $value)
17
    {
18 40
        $this->value = $value;
19
    }
20
21 2
    public function getAttributeValue(string $attribute): mixed
22
    {
23 2
        return null;
24
    }
25
26 37
    public function getData(): mixed
27
    {
28 37
        return $this->value;
29
    }
30
31
    public function hasAttribute(string $attribute): bool
32
    {
33
        return true;
34
    }
35
}
36