Completed
Pull Request — master (#490)
by Antoine
04:24 queued 01:05
created

ConfigurationMap::add()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %
Metric Value
dl 0
loc 8
rs 9.4285
cc 2
eloc 4
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace ApiPlatform\Core\Metadata\Resource;
13
14
/**
15
 * A map of resource configurations per resource class.
16
 *
17
 * @author Antoine Bluchet <[email protected]>
18
 */
19
final class ConfigurationMap implements \IteratorAggregate
20
{
21
    private $configurations;
22
23
    /**
24
     * @param string[] $classes
0 ignored issues
show
Bug introduced by
There is no parameter named $classes. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

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

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

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

Loading history...
25
     */
26
    public function __construct(array $configurations = [])
27
    {
28
        $this->configurations = $configurations;
29
    }
30
31
    /**
32
     * @param string $key
33
     * @param array  $value
34
     */
35
    public function add($key, $value)
36
    {
37
        if (isset($this->configurations[$key])) {
38
            return;
39
        }
40
41
        $this->configurations[$key] = $value;
42
    }
43
44
    public function get($key)
45
    {
46
        return $this->configurations[$key] ?? false;
47
    }
48
49
    /**
50
     * {@inheritdoc}
51
     */
52
    public function getIterator()
53
    {
54
        return new \ArrayIterator($this->configurations);
55
    }
56
}
57