Completed
Pull Request — master (#175)
by Alexander
02:53 queued 02:53
created

ArrayDataTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Test Coverage

Coverage 75%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 11
ccs 3
cts 4
cp 0.75
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A getAttributeValue() 0 7 2
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