This class seems to be duplicated in your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate
the same code in three or more different places, we strongly encourage you to
look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.
Loading history...
9
{
10
/**
11
* Returns the first element of this iterable or
12
* returns $default when this iterable is empty
13
*
14
* @param mixed $default
15
* @return mixed
16
*/
17
7
public function first($default = null)
18
{
19
7
if ($this instanceof \Iterator) {
20
6
$item = $default;
21
6
foreach ($this as $item) {
22
3
break;
23
}
24
6
return $item;
25
}
26
27
1
return null;
28
}
29
30
/**
31
* Returns the key of the first element of this iterable or
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.