InjectParams   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%
Metric Value
dl 0
loc 42
wmc 4
lcom 1
cbo 0
ccs 10
cts 10
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getIterator() 0 4 1
A count() 0 4 1
A getValue() 0 11 2
1
<?php
2
namespace mxdiModule\Annotation;
3
4
use mxdiModule\Exception\CannotGetValue;
5
use Zend\ServiceManager\ServiceLocatorInterface;
6
7
/**
8
 * @Annotation
9
 * @Target("METHOD")
10
 */
11
final class InjectParams implements \IteratorAggregate, \Countable, AnnotationInterface
12
{
13
    /** @var array */
14
    public $value = [];
15
16
    /**
17
     * @return array|\Traversable
18
     * @internal
19
     */
20 2
    public function getIterator()
21
    {
22 2
        return new \ArrayIterator($this->value);
23
    }
24
25
    /**
26
     * Get the value.
27
     *
28
     * @param ServiceLocatorInterface $sm
29
     * @return mixed
30
     *
31
     * @throws CannotGetValue
32
     */
33 1
    public function getValue(ServiceLocatorInterface $sm)
34
    {
35 1
        $value = [];
36
37
        /** @var Inject $injection */
38 1
        foreach ($this as $injection) {
39 1
            $value[] = $injection->getValue($sm);
40 1
        }
41
42 1
        return $value;
43
    }
44
45
    /**
46
     * @internal
47
     */
48 1
    public function count()
49
    {
50 1
        return count($this->value);
51
    }
52
}
53