Completed
Push — master ( 15f051...29343b )
by Oleg
05:33
created

HasAttributes::buildAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Malezha\Menu\Traits;
4
5
use Malezha\Menu\Entity\Attributes;
6
7
trait HasAttributes
8
{
9
    /**
10
     * @var Attributes
11
     */
12
    protected $attributes;
13
14
    /**
15
     * @param callable|null $callback
16
     * @return Attributes|mixed
17
     */
18 1
    public function getAttributes($callback = null)
19
    {
20 1
        if (is_callable($callback)) {
21
            return call_user_func($callback, $this->attributes);
22
        }
23
24 1
        return $this->attributes;
25
    }
26
27
    /**
28
     * @param array $attributes
29
     * @return string
30
     */
31 2
    public function buildAttributes($attributes = [])
32
    {
33 2
        return $this->attributes->build($attributes);
34
    }
35
}