ClassParser   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 92.86%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 15
c 1
b 0
f 0
dl 0
loc 48
ccs 13
cts 14
cp 0.9286
rs 10
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A obtainItemName() 0 3 1
A run() 0 5 1
A execAddNS() 0 17 3
1
<?php
2
3
namespace BultonFr\Annotation\Parsers;
4
5
use BultonFr\Annotation\Annotations\AddNS;
6
7
/**
8
 * Do action for annotation declared for all a class
9
 *
10
 * @package BultonFr\Annotation
11
 */
12
class ClassParser extends AbstractParser
13
{
14
    /**
15
     * {@inheritDoc}
16
     *
17
     * Use the annotation reader to obtain all Annotations\Info objects
18
     * Create AddNS instancies and add there to ParserManager
19
     * Instanciate all others annotations dedicated object
20
     */
21
    public function run()
22
    {
23 1
        $this->execAnnotReader();
24 1
        $this->execAddNS();
25 1
        $this->generateAllAnnotObject($this->obtainItemName());
26 1
    }
27
28
    /**
29
     * Return the item name sent to AbstractAnnotation
30
     *
31
     * @return string
32
     */
33
    protected function obtainItemName(): string
34
    {
35 1
        return 'class_'.$this->reflection->getName();
36
    }
37
38
    /**
39
     * Create AddNS's instancies and add the object to parserManager
40
     *
41
     * @return void
42
     */
43
    protected function execAddNS()
44
    {
45 1
        $annotList = $this->annotReader->getAnnotationList();
0 ignored issues
show
Bug introduced by
The method getAnnotationList() does not exist on null. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

45
        /** @scrutinizer ignore-call */ 
46
        $annotList = $this->annotReader->getAnnotationList();

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
46
        
47 1
        if (array_key_exists('AddNS', $annotList) === false) {
48
            return;
49
        }
50
        
51 1
        $nsList = $annotList['AddNS'];
52 1
        foreach ($nsList as $infoObj) {
53 1
            $ns = new AddNS(
54 1
                $this->parserManager->getReader(),
55 1
                $this->obtainItemName(),
56
                $infoObj
57
            );
58
            
59 1
            $this->parserManager->addImportedNS($ns->getNs(), $ns->getAlias());
60
        }
61 1
    }
62
}
63