Completed
Branch dev-master (5a9550)
by Derek Stephen
02:00
created

HasAttributesTrait::setAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * User: delboy1978uk
4
 * Date: 04/12/2016
5
 * Time: 15:01
6
 */
7
8
namespace Del\Form\Traits;
9
10
11
trait HasAttributesTrait
12
{
13
    /** @var array $attributes */
14
    private $attributes = [];
15
16
    /**
17
     * @param $key
18
     * @return mixed|string
19
     */
20 18
    public function getAttribute($key)
21
    {
22 18
        return isset($this->attributes[$key]) ? $this->attributes[$key] : null;
23
    }
24
25
    /**
26
     * @param $key
27
     * @param $value
28
     * @return $this
29
     */
30 20
    public function setAttribute($key, $value)
31
    {
32 20
        $this->attributes[$key] = $value;
33 20
        return $this;
34
    }
35
36
    /**
37
     * @param array $attributes
38
     * @return $this
39
     */
40 1
    public function setAttributes(array $attributes)
41
    {
42 1
        $this->attributes = $attributes;
43 1
        return $this;
44
    }
45
46
    /**
47
     * @return array
48
     */
49 6
    public function getAttributes()
50
    {
51 6
        return $this->attributes;
52
    }
53
}