Passed
Pull Request — master (#17)
by
unknown
06:49
created

RequestDataSet   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 17
ccs 7
cts 7
cp 1
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributeValue() 0 3 1
A hasAttribute() 0 3 1
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\RequestModel;
6
7
use Yiisoft\Arrays\ArrayHelper;
8
use Yiisoft\Validator\DataSetInterface;
9
10
final class RequestDataSet implements DataSetInterface
11
{
12
    private array $requestData;
13
14 5
    public function __construct(array $requestData)
15
    {
16 5
        $this->requestData = $requestData;
17 5
    }
18
19 5
    public function getAttributeValue(string $attribute)
20
    {
21 5
        return ArrayHelper::getValueByPath($this->requestData, $attribute, null);
22
    }
23
24 1
    public function hasAttribute(string $attribute): bool
25
    {
26 1
        return $this->getAttributeValue($attribute) !== null;
27
    }
28
}
29