GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — dev ( 40bda2...5b7120 )
by Андрей
04:01
created

AnnotationReader::loadMetadataForAction()   B

Complexity

Conditions 9
Paths 13

Size

Total Lines 57
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 57
rs 7.0745
cc 9
eloc 26
nc 13
nop 2

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * @link https://github.com/old-town/workflow-zf2-dispatch
4
 * @author  Malofeykin Andrey  <[email protected]>
5
 */
6
namespace OldTown\Workflow\ZF2\Dispatch\Metadata\Target\Dispatch;
7
8
use OldTown\Workflow\ZF2\Dispatch\Annotation;
9
use OldTown\Workflow\ZF2\Dispatch\Annotation\Condition;
10
use OldTown\Workflow\ZF2\Dispatch\Metadata\Reader\AbstractAnnotationReader;
11
12
/**
13
 * Class AnnotationReader
14
 *
15
 * @package OldTown\Workflow\ZF2\Dispatch\Metadata\Reader
16
 */
17
class AnnotationReader extends AbstractAnnotationReader
18
{
19
    /**
20
     * @var string
21
     */
22
    const READER_NAME = 'dispatchAnnotation';
23
24
    /**
25
     * Получение метаданных для action контроллера
26
     *
27
     * @param string  $controllerClassName
28
     * @param  string $actionMethod
29
     *
30
     * @return MetadataInterface
31
     * @throws Exception\AnnotationReaderException
32
     *
33
     * @throws Exception\InvalidMetadataException
34
     *
35
     */
36
    public function loadMetadataForAction($controllerClassName, $actionMethod)
37
    {
38
        $key = $controllerClassName . '_' . $actionMethod;
39
        if (array_key_exists($key, $this->classAnnotations)) {
40
            return $this->classAnnotations[$key];
41
        }
42
43
        $r = new \ReflectionClass($controllerClassName);
44
        $rMethod = $r->getMethod($actionMethod);
45
46
        $metadata = new Metadata();
47
48
49
        /** @var Annotation\WorkflowDispatch|null $workflowDispatchAnnotation */
50
        $workflowDispatchAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowDispatch::class);
51
        if (null !== $workflowDispatchAnnotation) {
52
            $metadata->setWorkflowDispatch($workflowDispatchAnnotation->enabled);
53
            $metadata->setWorkflowRunType($workflowDispatchAnnotation->activity);
54
        }
55
56
        /** @var Annotation\PrepareData|null $prepareDataAnnotation */
57
        $prepareDataAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\PrepareData::class);
58
        if ($prepareDataAnnotation) {
59
            $metadata->setFlagRunPrepareData($prepareDataAnnotation->enabled);
60
            $metadata->setPrepareDataMethod($prepareDataAnnotation->type);
61
            $metadata->setPrepareDataHandler($prepareDataAnnotation->handler);
62
        }
63
64
65
        /** @var Annotation\DispatchConditions|null $dispatchConditionsAnnotation */
66
        $dispatchConditionsAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\DispatchConditions::class);
67
        if ($dispatchConditionsAnnotation && is_array($dispatchConditionsAnnotation->conditions) && count($dispatchConditionsAnnotation->conditions) > 0) {
68
            $metadata->setFlagHasConditions(true);
69
            foreach ($dispatchConditionsAnnotation->conditions as $condition) {
70
                if (!$condition instanceof Condition) {
71
                    $errMsg = 'Invalid condition annotation';
72
                    throw new Exception\AnnotationReaderException($errMsg);
73
                }
74
                $conditionMetadata = new DispatchConditionMetadata($condition->type, $condition->handler, $condition->params);
75
76
                $metadata->addConditions($conditionMetadata);
77
            }
78
        }
79
//
0 ignored issues
show
Unused Code Comprehensibility introduced by
57% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
80
//        /** @var Annotation\WorkflowRouterMap|null $workflowRouterMapAnnotation */
81
//        $workflowRouterMapAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowRouterMap::class);
82
//        if ($workflowRouterMapAnnotation) {
83
//            $metadata->setWorkflowManagerNameRouterParam($workflowRouterMapAnnotation->managerName);
84
//            $metadata->setWorkflowActionNameRouterParam($workflowRouterMapAnnotation->actionName);
85
//            $metadata->setWorkflowNameRouterParam($workflowRouterMapAnnotation->name);
86
//            $metadata->setEntryIdRouterParam($workflowRouterMapAnnotation->entryId);
87
//        }
88
//
89
//        $metadata->validate();
90
91
        return $metadata;
92
    }
93
}
94