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

MixedDataSet   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 0
Metric Value
wmc 4
eloc 6
c 0
b 0
f 0
dl 0
loc 22
ccs 6
cts 8
cp 0.75
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getData() 0 3 1
A getAttributeValue() 0 3 1
A hasAttribute() 0 3 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