Branches::valid()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 6
ccs 0
cts 0
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 3
nc 2
nop 0
crap 6
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