Completed
Push — master ( 530ce9...1b2ae5 )
by Paweł
23:42 queued 20:31
created

ContextReader   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 1
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A read() 0 6 1
1
<?php
2
3
/**
4
 * This file is part of the Superdesk Web Publisher Template Engine Bundle.
5
 *
6
 * Copyright 2015 Sourcefabric z.u. and contributors.
7
 *
8
 * For the full copyright and license information, please see the
9
 * AUTHORS and LICENSE files distributed with this source code.
10
 *
11
 * @copyright 2015 Sourcefabric z.ú.
12
 * @license http://www.superdesk.org/license
13
 */
14
namespace SWP\Bundle\TemplateEngineBundle\Annotation;
15
16
use Doctrine\Common\Annotations\Reader;
17
18
class ContextReader
19
{
20
    private $reader;
21
22
    private $annotationClass = 'SWP\\Bundle\\TemplateEngineBundle\\Annotation\\Context';
23
24
    public function __construct(Reader $reader)
25
    {
26
        $this->reader = $reader;
27
    }
28
29
    /**
30
     * Read Context annotation from controller.
31
     *
32
     * @param object $originalObject Array with controller object and method name
33
     *
34
     * @return Context
35
     */
36
    public function read($originalObject)
37
    {
38
        $reflectionMethod = new \ReflectionMethod($originalObject[0], $originalObject[1]);
39
40
        return $this->reader->getMethodAnnotation($reflectionMethod, $this->annotationClass);
41
    }
42
}
43