InjectDoctrineRepository::getValue()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 8
loc 8
ccs 4
cts 4
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({"PROPERTY", "ANNOTATION", "METHOD"})
10
 */
11
final class InjectDoctrineRepository implements AnnotationInterface
12
{
13
    /**
14
     * FQCN of the entity
15
     * @var string
16
     */
17
    public $value;
18
19
    /**
20
     * Get the value.
21
     *
22
     * @param ServiceLocatorInterface|null $sm
23
     * @return object
24
     *
25
     * @throws CannotGetValue
26
     */
27 2 View Code Duplication
    public function getValue(ServiceLocatorInterface $sm)
28
    {
29
        try {
30 2
            return $sm->get('Doctrine\ORM\EntityManager')->getRepository($this->value);
31 1
        } catch (\Exception $e) {
32 1
            throw CannotGetValue::of(sprintf('repository of %s', $this->value), $e);
33
        }
34
    }
35
}
36