Passed
Push — master ( 4e94c9...4bfcda )
by Michael
02:19
created

UnknownDataTypeException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 35
ccs 8
cts 10
cp 0.8
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 12 1
A getDefinition() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Mapper\Handler\Exception;
5
6
use Mikemirten\Component\JsonApi\Mapper\Definition\Attribute;
7
8
/**
9
 * Exception of unknown data-type
10
 *
11
 * @package Mikemirten\Component\JsonApi\Mapper\Handler\Exception
12
 */
13
class UnknownDataTypeException extends MappingHandlerException
14
{
15
    /**
16
     * @var Attribute
17
     */
18
    protected $definition;
19
20
    /**
21
     * UnknownTypeException constructor.
22
     *
23
     * @param Attribute $definition
24
     */
25 2
    public function __construct(Attribute $definition)
26
    {
27 2
        $this->definition = $definition;
28
29 2
        $message = sprintf(
30 2
            'Unable to process unknown data-type "%s" of attribute "%s"',
31 2
            $definition->getType(),
32 2
            $definition->getName()
33
        );
34
35 2
        parent::__construct($message);
36 2
    }
37
38
    /**
39
     * Get definition of attribute caused the issue
40
     *
41
     * @return Attribute
42
     */
43
    public function getDefinition(): Attribute
44
    {
45
        return $this->definition;
46
    }
47
}