Passed
Push — master ( 4e9678...264ecb )
by Rustam
03:28 queued 01:15
created

RequestModel::getData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
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
    protected string $attributeDelimiter = '.';
13
14 13
    public function setRequestData(array $requestData): void
15
    {
16 13
        $this->requestData = $requestData;
17
    }
18
19 10
    public function getAttributeValue(string $attribute, $default = null)
20
    {
21 10
        return ArrayHelper::getValueByPath($this->requestData, $attribute, $default, $this->attributeDelimiter);
22
    }
23
24 1
    public function hasAttribute(string $attribute): bool
25
    {
26 1
        return ArrayHelper::pathExists($this->requestData, $attribute, true, $this->attributeDelimiter);
27
    }
28
29 2
    public function getRequestData(): array
30
    {
31 2
        return $this->requestData;
32
    }
33
34
    public function getData(): array
35
    {
36
        return $this->requestData;
37
    }
38
}
39