HasAttributes::getAttribute()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 2
eloc 2
nc 2
nop 2
1
<?php
2
3
4
namespace Sco\Bankcard\Traits;
5
6
trait HasAttributes
7
{
8
    protected $attributes = [];
9
10
    public function getAttributes()
11
    {
12
        return $this->attributes;
13
    }
14
15
    public function getAttribute($name, $default = null)
16
    {
17
        return isset($this->attributes[$name]) ? $this->attributes[$name] : $default;
18
    }
19
20
    public function setAttribute($name, $value)
21
    {
22
        $this->attributes[$name] = $value;
23
24
        return $this;
25
    }
26
27
    public function merge(array $attributes)
28
    {
29
        $this->attributes = array_merge($this->attributes, $attributes);
30
31
        return $this;
32
    }
33
}
34