Passed
Pull Request — master (#1)
by
unknown
14:51
created

RequestModel   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A getRequestData() 0 3 1
A setRequestData() 0 3 1
A hasValue() 0 3 1
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
    public function setRequestData(array $requestData): void
14
    {
15
        $this->requestData = $requestData;
16
    }
17
18
    public function getValue(string $field, $default = null)
19
    {
20
        return ArrayHelper::getValueByPath($this->requestData, $field, $default);
21
    }
22
23
    public function hasValue(string $field): bool
24
    {
25
        return $this->getValue($field) !== null;
26
    }
27
28
    public function getRequestData(): array
29
    {
30
        return $this->requestData;
31
    }
32
}
33