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

UnknownDataTypeException::getDefinition()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
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
}