Completed
Push — refactoring ( 84ac1f...ab1ebc )
by Oleg
04:25
created

HasAttributes   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 83.33%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 29
wmc 3
lcom 1
cbo 0
ccs 5
cts 6
cp 0.8333
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getAttributes() 0 8 2
A buildAttributes() 0 4 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
}