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

ItemCollection::setCurrent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

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