Passed
Push — 1.x ( 5dbfd8...9a028c )
by Ulises Jeremias
02:21
created

Iterator::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php namespace Mbh\Collection\Traits\Sequenceable;
2
3
/**
4
 * MBHFramework
5
 *
6
 * @link      https://github.com/MBHFramework/mbh-framework
7
 * @copyright Copyright (c) 2017 Ulises Jeremias Cornejo Fandos
8
 * @license   https://github.com/MBHFramework/mbh-framework/blob/master/LICENSE (MIT License)
9
 */
10
11
use Traversable;
12
13
trait Iterator
14
{
15
    protected $sfa = null;
16
17
    /**
18
     * Create an fixed array
19
     *
20
     * @param Traversable $array data
21
     */
22
    protected function __construct(Traversable $array)
23
    {
24
        $this->sfa = $array;
25
        $this->checkCapacity();
0 ignored issues
show
Bug introduced by
It seems like checkCapacity() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

25
        $this->/** @scrutinizer ignore-call */ 
26
               checkCapacity();
Loading history...
26
    }
27
28
    /**
29
     * Iterator
30
     */
31
    public function current()
32
    {
33
        return $this->sfa->current();
34
    }
35
36
    public function key(): int
37
    {
38
        return $this->sfa->key();
39
    }
40
41
    public function next()
42
    {
43
        return $this->sfa->next();
44
    }
45
46
    public function rewind()
47
    {
48
        return $this->sfa->rewind();
49
    }
50
51
    public function valid()
52
    {
53
        return $this->sfa->valid();
54
    }
55
}
56