AllTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 35
loc 35
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A all() 17 17 4

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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