Completed
Push — master ( 3a2809...fa6500 )
by Pieter
03:01
created

Branches   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 41
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 4 1
A count() 0 4 1
A rewind() 0 4 1
A current() 0 4 1
A key() 0 4 1
A next() 0 4 1
A valid() 0 6 2
1
<?php declare(strict_types=1);
2
3
namespace Gitilicious\GitClient\Git;
4
5
class Branches implements \Countable, \Iterator
6
{
7
    private $branches = [];
8
9 1
    public function add(Branch $branch)
10
    {
11 1
        $this->branches[] = $branch;
12 1
    }
13
14
    public function count(): int
15
    {
16
        return count($this->branches);
17
    }
18
19
    public function rewind()
20
    {
21
        reset($this->branches);
22
    }
23
24
    public function current(): Branch
25
    {
26
        return current($this->branches);
27
    }
28
29
    public function key(): int
30
    {
31
        return key($this->branches);
32
    }
33
34
    public function next(): Branch
35
    {
36
        return next($this->branches);
37
    }
38
39
    public function valid(): bool
40
    {
41
        $key = key($this->branches);
42
43
        return ($key !== null && $key !== false);
44
    }
45
}
46