UnderscoreAliases::uniq()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
/*
4
 * This file is part of the PHP-UNDERSCORE package.
5
 *
6
 * (c) Jitendra Adhikari <[email protected]>
7
 *     <https://github.com/adhocore>
8
 *
9
 * Licensed under MIT license.
10
 */
11
12
namespace Ahc\Underscore;
13
14
trait UnderscoreAliases
15
{
16
    /**
17
     * Alias of first().
18
     *
19
     * @param int $n
20
     *
21
     * @return array|mixed With n = 1 (default), it gives one item, which may not be array.
22
     */
23
    public function head($n = 1)
24
    {
25
        return $this->first($n);
0 ignored issues
show
Bug introduced by
It seems like first() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        return $this->/** @scrutinizer ignore-call */ first($n);
Loading history...
26
    }
27
28
    /**
29
     * Alias of first().
30
     *
31
     * @param int $n
32
     *
33
     * @return array|mixed With n = 1 (default), it gives one item, which may not be array.
34
     */
35
    public function take($n = 1)
36
    {
37
        return $this->first($n);
38
    }
39
40
    /**
41
     * Alias of last().
42
     *
43
     * @param int $n
44
     *
45
     * @return array|mixed With n = 1 (default), it gives one item, which may not be array.
46
     */
47
    public function tail($n = 1)
48
    {
49
        return $this->last($n);
0 ignored issues
show
Bug introduced by
It seems like last() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

49
        return $this->/** @scrutinizer ignore-call */ last($n);
Loading history...
50
    }
51
52
    /**
53
     * Alias of last().
54
     *
55
     * @param int $n
56
     *
57
     * @return array|mixed With n = 1 (default), it gives one item, which may not be array.
58
     */
59
    public function drop($n = 1)
60
    {
61
        return $this->last($n);
62
    }
63
64
    /**
65
     * Alias of unique().
66
     *
67
     * @param callable|string $fn The callback. String is resolved to value of that index.
68
     *
69
     * @return self
70
     */
71
    public function uniq($fn = null)
72
    {
73
        return $this->unique($fn);
0 ignored issues
show
Bug introduced by
The method unique() does not exist on Ahc\Underscore\UnderscoreAliases. Did you maybe mean uniq()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

73
        return $this->/** @scrutinizer ignore-call */ unique($fn);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
74
    }
75
76
    /**
77
     * Alias of difference().
78
     *
79
     * @param array|mixed $data Array or array like or array convertible.
80
     *
81
     * @return self
82
     */
83
    public function without($data)
84
    {
85
        return $this->difference($data);
0 ignored issues
show
Bug introduced by
It seems like difference() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

85
        return $this->/** @scrutinizer ignore-call */ difference($data);
Loading history...
86
    }
87
88
    /**
89
     * Alias of map().
90
     *
91
     * @param callable $fn The callback.
92
     *
93
     * @return self
94
     */
95
    public function collect(callable $fn)
96
    {
97
        return $this->map($fn);
0 ignored issues
show
Bug introduced by
It seems like map() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

97
        return $this->/** @scrutinizer ignore-call */ map($fn);
Loading history...
98
    }
99
100
    /**
101
     * Alias of reduce().
102
     *
103
     * @param callable $fn   The callback.
104
     * @param mixed    $memo The initial value carried over to each iteration and returned finally.
105
     *
106
     * @return mixed
107
     */
108
    public function foldl(callable $fn, $memo)
109
    {
110
        return $this->reduce($fn, $memo);
0 ignored issues
show
Bug introduced by
It seems like reduce() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

110
        return $this->/** @scrutinizer ignore-call */ reduce($fn, $memo);
Loading history...
111
    }
112
113
    /**
114
     * Alias of reduce().
115
     *
116
     * @param callable $fn   The callback.
117
     * @param mixed    $memo The initial value carried over to each iteration and returned finally.
118
     *
119
     * @return mixed
120
     */
121
    public function inject(callable $fn, $memo)
122
    {
123
        return $this->reduce($fn, $memo);
124
    }
125
126
    /**
127
     * Alias of reduceRight().
128
     *
129
     * @param callable $fn   The callback.
130
     * @param mixed    $memo The initial value carried over to each iteration and returned finally.
131
     *
132
     * @return mixed
133
     */
134
    public function foldr(callable $fn, $memo)
135
    {
136
        return $this->reduceRight($fn, $memo);
0 ignored issues
show
Bug introduced by
It seems like reduceRight() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

136
        return $this->/** @scrutinizer ignore-call */ reduceRight($fn, $memo);
Loading history...
137
    }
138
139
    /**
140
     * Alias of find().
141
     *
142
     * @param callable $fn       The truth test callback.
143
     * @param bool     $useValue Whether to return value or the index on match.
144
     *
145
     * @return mixed|null
146
     */
147
    public function detect(callable $fn)
148
    {
149
        return $this->find($fn);
0 ignored issues
show
Bug introduced by
It seems like find() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

149
        return $this->/** @scrutinizer ignore-call */ find($fn);
Loading history...
150
    }
151
152
    /**
153
     * Alias of filter().
154
     *
155
     * @param callable|string|null $fn The truth test callback.
156
     *
157
     * @return self
158
     */
159
    public function select(callable $fn = null)
160
    {
161
        return $this->filter($fn);
0 ignored issues
show
Bug introduced by
It seems like filter() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

161
        return $this->/** @scrutinizer ignore-call */ filter($fn);
Loading history...
162
    }
163
164
    /**
165
     * Alias of every().
166
     *
167
     * @param callable $fn The truth test callback.
168
     *
169
     * @return bool
170
     */
171
    public function all(callable $fn)
172
    {
173
        return $this->every($fn);
0 ignored issues
show
Bug introduced by
It seems like every() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

173
        return $this->/** @scrutinizer ignore-call */ every($fn);
Loading history...
174
    }
175
176
    /**
177
     * Alias of some().
178
     *
179
     * @param callable $fn The truth test callback.
180
     *
181
     * @return bool
182
     */
183
    public function any(callable $fn)
184
    {
185
        return $this->some($fn);
0 ignored issues
show
Bug introduced by
It seems like some() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

185
        return $this->/** @scrutinizer ignore-call */ some($fn);
Loading history...
186
    }
187
188
    /**
189
     * Alias of contains().
190
     */
191
    public function includes($item)
192
    {
193
        return $this->contains($item);
0 ignored issues
show
Bug introduced by
It seems like contains() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

193
        return $this->/** @scrutinizer ignore-call */ contains($item);
Loading history...
194
    }
195
196
    /**
197
     * Alias of count().
198
     *
199
     * @return int
200
     */
201
    public function size()
202
    {
203
        return $this->count();
0 ignored issues
show
Bug introduced by
It seems like count() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

203
        return $this->/** @scrutinizer ignore-call */ count();
Loading history...
204
    }
205
}
206