Passed
Push — master ( 66adc4...f8e97d )
by Alexander
10:22
created

Magic   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 7
dl 0
loc 21
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Arrays\Tests;
6
7
final class Magic
8
{
9
    private array $attributes;
10
11
    public function __construct(array $attributes)
12
    {
13
        $this->attributes = $attributes;
14
    }
15
16
    public function __get(string $attribute)
17
    {
18
        if (!array_key_exists($attribute, $this->attributes)) {
19
            throw new \InvalidArgumentException("There is no \"$attribute\"");
20
        }
21
22
        return $this->attributes[$attribute];
23
    }
24
25
    public function __set(string $attribute, $value)
26
    {
27
        $this->attributes[$attribute] = $value;
28
    }
29
}
30