Passed
Push — master ( 29521a...b34be3 )
by Alexander
24:53 queued 23:31
created

RequestModel::getValue()   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 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\RequestModel;
6
7
use Yiisoft\Arrays\ArrayHelper;
8
9
abstract class RequestModel implements RequestModelInterface
10
{
11
    private array $requestData = [];
12
13 10
    public function setRequestData(array $requestData): void
14
    {
15 10
        $this->requestData = $requestData;
16 10
    }
17
18 7
    public function getValue(string $field, $default = null)
19
    {
20 7
        return ArrayHelper::getValueByPath($this->requestData, $field, $default);
21
    }
22
23 1
    public function hasValue(string $field): bool
24
    {
25 1
        return $this->getValue($field) !== null;
26
    }
27
28 2
    public function getRequestData(): array
29
    {
30 2
        return $this->requestData;
31
    }
32
}
33