GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Set   A
last analyzed

Complexity

Total Complexity 12

Size/Duplication

Total Lines 117
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 12
lcom 1
cbo 2
dl 0
loc 117
rs 10
c 0
b 0
f 0

8 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 6 1
A has() 0 10 3
A get() 0 13 3
A rewind() 0 4 1
A current() 0 4 1
A key() 0 4 1
A next() 0 4 1
A valid() 0 4 1
1
<?php
2
namespace Naneau\FileGen\Parameter;
3
4
use Naneau\FileGen\Exception as FileGenException;
5
6
use \Iterator;
7
8
/**
9
 * A set of parameters
10
 */
11
class Set implements Iterator
12
{
13
    /**
14
     * Position of the iteration
15
     *
16
     * @var int
17
     **/
18
    private $position = 0;
19
20
    /**
21
     * Parameters
22
     *
23
     * @var Parameter[]
24
     **/
25
    private $parameters = array();
26
27
    /**
28
     * Add a new parameter
29
     *
30
     * @param  string $name        name of the parameter
31
     * @param  string $description (optional) human readable description
32
     * @return Set
33
     **/
34
    public function add($name, $description = null)
35
    {
36
        $this->parameters[] = new Parameter($name, $description);
37
38
        return $this;
39
    }
40
41
    /**
42
     * Is there a parameter with name $name?
43
     *
44
     * @param  string $name
45
     * @return bool
46
     **/
47
    public function has($name)
48
    {
49
        foreach ($this as $parameter) {
50
            if ($parameter->getName() === $name) {
51
                return true;
52
            }
53
        }
54
55
        return false;
56
    }
57
58
    /**
59
     * Get a parameter by name
60
     *
61
     * @param  string    $name
62
     * @return Parameter
63
     **/
64
    public function get($name)
65
    {
66
        foreach ($this as $parameter) {
67
            if ($parameter->getName() === $name) {
68
                return $parameter;
69
            }
70
        }
71
72
        throw new FileGenException(sprintf(
73
            'Can not find parameter "%s"',
74
            $name
75
        ));
76
    }
77
78
    /**
79
     * Rewind iterator
80
     *
81
     * @return void
82
     **/
83
    public function rewind()
84
    {
85
        $this->position = 0;
86
    }
87
88
    /**
89
     * Get current parameter
90
     *
91
     * @return Parameter
92
     **/
93
    public function current()
94
    {
95
        return $this->parameters[$this->position];
96
    }
97
98
    /**
99
     * Get current key
100
     *
101
     * @return int
102
     **/
103
    public function key()
104
    {
105
        return $this->position;
106
    }
107
108
    /**
109
     * Go to next position
110
     *
111
     * @return void
112
     **/
113
    public function next()
114
    {
115
        ++$this->position;
116
    }
117
118
    /**
119
     * Is the iterator in a valid position?
120
     *
121
     * @return bool
122
     **/
123
    public function valid()
124
    {
125
        return isset($this->parameters[$this->position]);
126
    }
127
}
128