ClassProcessor   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 4
dl 0
loc 27
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 18 5
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 4
    public function process(\ReflectionClass $reflection, Definition $definition)
24
    {
25 4
        $annotations = $this->reader->getClassAnnotations($reflection);
26
27 4
        foreach ($annotations as $annotation)
28
        {
29 4
            if ($annotation instanceof Link) {
30 3
                $link = $this->createLink($annotation);
31
32 3
                $definition->addLink($link);
33 3
                continue;
34
            }
35
36 3
            if ($annotation instanceof ResourceIdentifier && $annotation->type !== null) {
37 3
                $definition->setType($annotation->type);
38
            }
39
        }
40
    }
41
}