Test Failed
Push — master ( 385400...b007ca )
by Michael
02:12
created

ClassProcessor::process()   B

Complexity

Conditions 5
Paths 4

Size

Total Lines 18
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 18
rs 8.8571
cc 5
eloc 9
nc 4
nop 2
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Mapper\Definition\AnnotationProcessor;
5
6
use Mikemirten\Component\JsonApi\Mapper\Definition\Annotation\ResourceIdentifier;
7
use Mikemirten\Component\JsonApi\Mapper\Definition\Annotation\Link;
8
use Mikemirten\Component\JsonApi\Mapper\Definition\Definition;
9
10
/**
11
 * Processor of annotations of class
12
 *
13
 * @package Mikemirten\Component\JsonApi\Mapper\Definition\AnnotationProcessor
14
 */
15
class ClassProcessor extends AbstractProcessor
16
{
17
    /**
18
     * Process annotations
19
     *
20
     * @param \ReflectionClass $reflection
21
     * @param Definition       $definition
22
     */
23
    public function process(\ReflectionClass $reflection, Definition $definition): void
24
    {
25
        $annotations = $this->reader->getClassAnnotations($reflection);
26
27
        foreach ($annotations as $annotation)
28
        {
29
            if ($annotation instanceof Link) {
30
                $link = $this->createLink($annotation);
31
32
                $definition->addLink($link);
33
                continue;
34
            }
35
36
            if ($annotation instanceof ResourceIdentifier && $annotation->type !== null) {
37
                $definition->setType($annotation->type);
38
            }
39
        }
40
    }
41
}