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

ItemCollection::setCurrent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 5
cp 0
rs 9.4286
cc 1
eloc 3
nc 1
nop 1
crap 2
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