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

ConfigurationMap   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0
Metric Value
wmc 5
lcom 1
cbo 0
dl 0
loc 38
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A add() 0 8 2
A get() 0 4 1
A getIterator() 0 4 1
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