ManualCountIterator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 26
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A count() 0 4 1
1
<?php
2
3
namespace Indigo\Iterator;
4
5
/**
6
 * Wraps an iterator and allows to set the count manually.
7
 *
8
 * Example: based on database COUNT result.
9
 *
10
 * @author Márk Sági-Kazár <[email protected]>
11
 */
12
class ManualCountIterator extends \IteratorIterator implements \Countable
13
{
14
    /**
15
     * @var int
16
     */
17
    protected $count;
18
19
    /**
20
     * @param \Traversable $iterator
21
     * @param int          $count
22
     */
23 1
    public function __construct(\Traversable $iterator, $count)
24
    {
25 1
        $this->count = $count;
26
27 1
        parent::__construct($iterator);
28 1
    }
29
30
    /**
31
     * {@inheritdoc}
32
     */
33 1
    public function count()
34
    {
35 1
        return $this->count;
36
    }
37
}
38