Issues (26)

src/Constraint/Arrays/ArrayUtility.php (1 issue)

1
<?php declare(strict_types=1);
2
3
4
namespace Pitchart\Phlunit\Constraint\Arrays;
5
6
class ArrayUtility
7
{
8 36
    public static function isAssociative(array $array): bool
9
    {
10 36
        $size = \count($array);
11 36
        $filteredKeys = \array_filter(\array_keys($array), function($int) {return $int === (int) $int; });
12 36
        return \count($filteredKeys) !== $size;
13
    }
14
15 4
    public static function isIndexed(array $array): bool
16
    {
17 4
        return !self::isAssociative($array);
18
    }
19
20 66
    public static function toArray(iterable $iterable): array
21
    {
22 66
        if ($iterable instanceof \Traversable) {
23 27
            return \iterator_to_array($iterable);
24
        }
25
26 57
        return $iterable;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $iterable returns the type iterable which is incompatible with the type-hinted return array.
Loading history...
27
    }
28
}
29