RequestModel   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 28
ccs 8
cts 10
cp 0.8
rs 10
c 1
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getRequestData() 0 3 1
A hasAttribute() 0 3 1
A setRequestData() 0 3 1
A getAttributeValue() 0 3 1
A getData() 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
    protected string $attributeDelimiter = '.';
13
14 10
    public function setRequestData(array $requestData): void
15
    {
16 10
        $this->requestData = $requestData;
17
    }
18
19 6
    public function getAttributeValue(string $attribute, mixed $default = null): mixed
20
    {
21 6
        return ArrayHelper::getValueByPath($this->requestData, $attribute, $default, $this->attributeDelimiter);
22
    }
23
24 3
    public function hasAttribute(string $attribute): bool
25
    {
26 3
        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