Passed
Pull Request — master (#351)
by
unknown
02:56
created

SingleValueDataSet::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

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