Passed
Push — master ( fad3cd...8c9440 )
by Michael
02:31
created

ClassProcessor::process()   A

Complexity

Conditions 4
Paths 6

Size

Total Lines 17
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 9
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 17
ccs 9
cts 9
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 6
nop 2
crap 4
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Mapper\Definition\ConfigurationProcessor;
5
6
use Mikemirten\Component\JsonApi\Mapper\Definition\Definition;
7
8
/**
9
 * Processor of configuration of class
10
 *
11
 * @package Mikemirten\Component\JsonApi\Mapper\Definition\ConfigurationProcessor
12
 */
13
class ClassProcessor extends AbstractProcessor
14
{
15
    /**
16
     * {@inheritdoc}
17
     */
18 2
    public function process(array $config, Definition $definition)
19
    {
20 2
        if (isset($config['type'])) {
21 1
            $definition->setType($config['type']);
22
        }
23
24 2
        if (! isset($config['links'])) {
25 1
            return;
26
        }
27
28 1
        foreach ($config['links'] as $linkName => $linkData)
29
        {
30 1
            $link = $this->createLink($linkName, $linkData);
31
32 1
            $definition->addLink($link);
33
        }
34
    }
35
}