Completed
Push — master ( 8e8eee...0073f8 )
by wen
12:40
created

Extension::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 0
1
<?php
2
3
namespace Sco\Admin\View\Extensions;
4
5
use Illuminate\Support\Collection;
6
use Sco\Admin\Contracts\View\Extensions\ExtensionInterface;
7
8
abstract class Extension extends Collection implements ExtensionInterface
9
{
10
11
    abstract public function add($value);
12
13
    /**
14
     * Wipe item.
15
     *
16
     * @return $this
17
     */
18
    public function clear()
19
    {
20
        $this->items = [];
21
22
        return $this;
23
    }
24
25
    /**
26
     * @param $values
27
     *
28
     * @return $this
29
     */
30
    public function set($values)
31
    {
32
        $this->clear();
33
34
        if (!is_array($values)) {
35
            $values = func_get_args();
36
        }
37
38
        foreach ($values as $value) {
39
            $this->add($value);
40
        }
41
42
        return $this;
43
    }
44
45
}
46