Passed
Pull Request — master (#20)
by Alex
01:39
created

EnumerationTrait::setEnumeration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
namespace AlgoWeb\xsdTypes\Facets;
3
4
trait EnumerationTrait
5
{
6
    /**
7
     * @Exclude
8
     * @var array Defines a list of acceptable values
9
     */
10
    private $enumeration = null;
11
12
    /**
13
     * @param array $enumorationValues Defines a list of acceptable values
14
     */
15
    protected function setEnumeration(array $enumorationValues)
16
    {
17
        $this->enumeration = $enumorationValues;
18
    }
19
20
    /**
21
     * @param string $enumorationValue adds a value to the enumeration set.
0 ignored issues
show
Documentation introduced by
There is no parameter named $enumorationValue. Did you maybe mean $enumerationValue?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit.

Consider the following example. The parameter $ireland is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $ireland
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was changed, but the annotation was not.

Loading history...
22
     */
23
    protected function addEnumeration($enumerationValue)
24
    {
25
        if (!is_array($this->enumeration)) {
26
            $this->enumeration = [];
27
        }
28
        $this->enumeration[] = $enumerationValue;
29
    }
30
31
    private function checkEnumeration($v)
32
    {
33
        if (is_array($this->enumeration) && 0 != count($this->enumeration) && !in_array($v, $this->enumeration)) {
34
            throw new \InvalidArgumentException(
35
                "The provided value for " . __CLASS__ . " is not " .
36
                implode(" || ", $this->enumeration)
37
            );
38
        }
39
    }
40
}
41