iterable_count()   A
last analyzed

Complexity

Conditions 3
Paths 4

Size

Total Lines 4
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
eloc 1
nc 4
nop 1
dl 0
loc 4
ccs 1
cts 1
cp 1
crap 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Improved;
6
7
/**
8
 * Count element of an iterable.
9
 *
10
 * @param iterable $iterable
11
 * @return int
12
 */
13
function iterable_count(iterable $iterable): int
0 ignored issues
show
introduced by
Function Improved\iterable_count() has parameter $iterable with no value type specified in iterable type iterable.
Loading history...
14
{
15
    /** @var array|\Traversable $iterable */
16 8
    return is_array($iterable) || $iterable instanceof \Countable ? count($iterable) : iterator_count($iterable);
17
}
18