CountableTrait::count()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 0
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 2
rs 10
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
trait CountableTrait
9
{
10
    /**
11
     * Count elements of an object
12
     *
13
     * @link http://php.net/manual/en/countable.count.php
14
     * @return int
15
     */
16 132
    public function count()
17
    {
18 132
        if ($this instanceof \Iterator) {
19 131
            return iterator_count($this);
20
        }
21
22 1
        return null;
23
    }
24
}
25