HasAttributesTrait   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setAttribute() 0 3 1
A setAttributes() 0 3 1
A getAttributes() 0 3 1
A getAttribute() 0 3 2
1
<?php
2
3
namespace Del\Form\Traits;
4
5
6
trait HasAttributesTrait
7
{
8
    private array $attributes = [];
9
10 68
    public function getAttribute(string $key): mixed
11
    {
12 68
        return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
13
    }
14
15 71
    public function setAttribute(string $key, $value): void
16
    {
17 71
        $this->attributes[$key] = $value;
18
    }
19
20 1
    public function setAttributes(array $attributes): void
21
    {
22 1
        $this->attributes = $attributes;
23
    }
24
25 36
    public function getAttributes(): array
26
    {
27 36
        return $this->attributes;
28
    }
29
}
30