InjectDoctrine::getValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 5
cp 1
rs 9.4285
cc 2
eloc 6
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({"PROPERTY", "ANNOTATION", "METHOD"})
10
 */
11
final class InjectDoctrine implements AnnotationInterface
12
{
13
    /**
14
     * Get the value.
15
     *
16
     * @param ServiceLocatorInterface|null $sm
17
     * @return object
18
     *
19
     * @throws CannotGetValue
20
     */
21 2
    public function getValue(ServiceLocatorInterface $sm)
22
    {
23 2
        $name = 'Doctrine\ORM\EntityManager';
24
25
        try {
26 2
            return $sm->get($name);
27 1
        } catch (\Exception $e) {
28 1
            throw CannotGetValue::of($name, $e);
29
        }
30
    }
31
}
32