Completed
Push — master ( fe2965...b756cf )
by ARCANEDEV
09:04
created

Collection::groupBy()   B

Complexity

Conditions 6
Paths 7

Size

Total Lines 24
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 16
CRAP Score 6

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 6
eloc 12
c 2
b 0
f 0
nc 7
nop 2
dl 0
loc 24
ccs 16
cts 16
cp 1
crap 6
rs 8.5125
1
<?php namespace Arcanedev\Support;
2
3
use Illuminate\Support\Collection as IlluminateCollection;
4
5
/**
6
 * Class     Collection
7
 *
8
 * @package  Arcanedev\Support
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class Collection extends IlluminateCollection
12
{
13
    /* ------------------------------------------------------------------------------------------------
14
     |  Illuminate Functions
15
     | ------------------------------------------------------------------------------------------------
16
     */
17
    /**
18
     * Filter items by the given key value pair.
19
     *
20
     * @param  string  $key
21
     * @param  array   $values
22
     * @param  bool    $strict
23
     *
24
     * @return static
25
     */
26
    public function whereIn($key, array $values, $strict = true)
27
    {
28 8
        return $this->filter(function ($item) use ($key, $values, $strict) {
29 8
            return in_array(data_get($item, $key), $values, $strict);
30 8
        });
31
    }
32
33
    /* ------------------------------------------------------------------------------------------------
34
     |  Custom Functions
35
     | ------------------------------------------------------------------------------------------------
36
     */
37
    /**
38
     * Reset the collection.
39
     *
40
     * @return self
41
     */
42 8
    public function reset()
43
    {
44 8
        $this->items = [];
45
46 8
        return $this;
47
    }
48
}
49