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

HasAttributes::getAttributes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 2.0625
Metric Value
dl 0
loc 8
ccs 3
cts 4
cp 0.75
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2.0625
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
}