AllTrait::all()   A
last analyzed

Complexity

Conditions 4
Paths 4

Size

Total Lines 17

Duplication

Lines 17
Ratio 100 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
cc 4
nc 4
nop 1
dl 17
loc 17
ccs 9
cts 9
cp 1
crap 4
rs 9.7
c 0
b 0
f 0
1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Itertools\lib\Traits;
7
8
use Zicht\Itertools\conversions;
9
10 View Code Duplication
trait AllTrait
0 ignored issues
show
Duplication introduced by
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...
11
{
12
    /**
13
     * Returns true when all elements of this iterable are not empty, otherwise returns false
14
     *
15
     * When the optional $STRATEGY argument is given, this argument is used to obtain the
16
     * value which is tested to be empty.
17
     *
18
     * > iterable([1, 'hello world', true])->all()
19
     * true
20
     *
21
     * > iterable([1, null, 3])->all()
22
     * false
23
     *
24
     * @param null|string|\Closure $strategy Optional, when not specified !empty will be used
25
     * @return null|bool
26
     */
27 16
    public function all($strategy = null)
28
    {
29 16
        if ($this instanceof \Iterator) {
30 15
            $strategy = conversions\mixed_to_value_getter($strategy);
0 ignored issues
show
Deprecated Code introduced by
The function Zicht\Itertools\conversi...mixed_to_value_getter() has been deprecated with message: Use \Zicht\Itertools\util\Conversions::mixedToClosure, will be removed in version 3.0

This function has been deprecated. The supplier of the file has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed from the class and what other function to use instead.

Loading history...
31
32 15
            foreach ($this as $item) {
33 13
                $tempVarPhp54 = call_user_func($strategy, $item);
34 13
                if (empty($tempVarPhp54)) {
35 13
                    return false;
36
                }
37
            }
38
39 8
            return true;
40
        }
41
42 1
        return null;
43
    }
44
}
45