Completed
Push — master ( 7e75f8...53d3fb )
by Ryan
10:44 queued 05:05
created

Collection::undecorate()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php namespace Anomaly\Streams\Platform\Support;
2
3
/**
4
 * Class Collection
5
 *
6
 * @link   http://pyrocms.com/
7
 * @author PyroCMS, Inc. <[email protected]>
8
 * @author Ryan Thompson <[email protected]>
9
 */
10
class Collection extends \Illuminate\Support\Collection
11
{
12
13
    /**
14
     * Alias for pluck.
15
     *
16
     * @deprecated in 3.1. Will remove in 3.2
17
     *
18
     * @param string $value
19
     * @param string $key
20
     *
21
     * @return $this
22
     */
23
    public function lists($value, $key = null)
24
    {
25
        return self::pluck($value, $key);
26
    }
27
28
    /**
29
     * Pad to the specified size with a value.
30
     *
31
     * @param        $size
32
     * @param  null  $value
33
     * @return $this
34
     */
35
    public function pad($size, $value = null)
36
    {
37
        if ($this->isEmpty()) {
38
            return $this;
39
        }
40
41
        return new static(array_pad($this->items, $size, $value));
42
    }
43
44
    /**
45
     * An alias for slice.
46
     *
47
     * @param $offset
48
     * @return $this
49
     */
50
    public function skip($offset)
51
    {
52
        return $this->slice($offset, null, true);
0 ignored issues
show
Unused Code introduced by
The call to Collection::slice() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
53
    }
54
55
    /**
56
     * Return undecorated items.
57
     *
58
     * @return static|$this
59
     */
60
    public function undecorate()
61
    {
62
        return new static((new Decorator())->undecorate($this->items));
63
    }
64
65
    /**
66
     * Map to get.
67
     *
68
     * @param $name
69
     * @return mixed
70
     */
71
    public function __get($name)
72
    {
73
        if ($this->has($name)) {
74
            return $this->get($name);
75
        }
76
77
        return call_user_func([$this, camel_case($name)]);
78
    }
79
80
    /**
81
     * Map to get.
82
     *
83
     * @param string $method
84
     * @param array  $parameters
85
     */
86
    public function __call($method, $parameters)
87
    {
88
        return $this->get($method);
89
    }
90
}
91