| 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
Loading history...
|
|||
| 14 | { |
||
| 15 | /** @var array|\Traversable $iterable */ |
||
| 16 | 8 | return is_array($iterable) || $iterable instanceof \Countable ? count($iterable) : iterator_count($iterable); |
|
| 17 | } |
||
| 18 |