Completed
Push — master ( f23563...5ddca9 )
by ARCANEDEV
03:15
created

ItemCollection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 38
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setCurrent() 0 6 1
A hasActiveItem() 0 6 1
1
<?php namespace Arcanesoft\Sidebar\Entities;
2
3
use Illuminate\Support\Collection;
4
5
/**
6
 * Class     ItemCollection
7
 *
8
 * @package  Arcanesoft\Core\Helpers\Sidebar\Entities
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class ItemCollection extends Collection
12
{
13
    /* -----------------------------------------------------------------
14
     |  Getters & Setters
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Set the current name to the items collection.
20
     *
21
     * @param  string  $currentName
22
     *
23
     * @return self
24
     */
25 6
    public function setCurrent($currentName)
26
    {
27
        return $this->transform(function (Item $item) use ($currentName) {
28 3
            return $item->setCurrent($currentName);
29 6
        });
30
    }
31
32
    /* -----------------------------------------------------------------
33
     |  Check Methods
34
     | -----------------------------------------------------------------
35
     */
36
37
    /**
38
     * Check if the items collection has an active one.
39
     *
40
     * @return bool
41
     */
42
    public function hasActiveItem()
43
    {
44 6
        return $this->filter(function (Item $item) {
45 3
            return $item->isActive();
46 6
        })->isNotEmpty();
47
    }
48
}
49