InjectParams::getValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2
Metric Value
dl 0
loc 11
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 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