Completed
Push — master ( 2b3dd9...7d2542 )
by ARCANEDEV
08:42
created

ItemCollection   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setCurrent() 0 6 1
A hasActiveItem() 0 8 1
1
<?php namespace Arcanesoft\Core\Helpers\Sidebar\Entities;
2
3
use Arcanedev\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
     * Set the current name to the items collection.
19
     *
20
     * @param  string  $currentName
21
     *
22
     * @return self
23
     */
24
    public function setCurrent($currentName)
25
    {
26
        return $this->map(function (Item $item) use ($currentName) {
27
            return $item->setCurrent($currentName);
28
        });
29
    }
30
31
    /* ------------------------------------------------------------------------------------------------
32
     |  Check Functions
33
     | ------------------------------------------------------------------------------------------------
34
     */
35
    /**
36
     * Check if the items collection has an active one.
37
     *
38
     * @return bool
39
     */
40
    public function hasActiveItem()
41
    {
42
        $activeItems = $this->filter(function (Item $item) {
43
            return $item->isActive();
44
        });
45
46
        return ! $activeItems->isEmpty();
47
    }
48
}
49