Passed
Pull Request — master (#222)
by Rustam
02:28
created

ArrayDataTrait::getData()   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 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 0
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\Validator\DataSet;
6
7
use Yiisoft\Validator\Exception\MissingAttributeException;
8
9
/**
10
 * @internal
11
 */
12
trait ArrayDataTrait
13
{
14
    private array $data;
15
16 1
    public function getAttributeValue(string $attribute)
17
    {
18 1
        if (!isset($this->data[$attribute])) {
19
            throw new MissingAttributeException("There is no \"$attribute\" key in the array.");
20
        }
21
22 1
        return $this->data[$attribute];
23
    }
24
25 3
    public function getData(): array
26
    {
27 3
        return $this->data;
28
    }
29
}
30