AttributeNotFoundException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 53
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 53
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A getName() 0 4 1
A getResource() 0 4 1
1
<?php
2
declare(strict_types = 1);
3
4
namespace Mikemirten\Component\JsonApi\Document\Exception;
5
6
use Mikemirten\Component\JsonApi\Document\ResourceObject;
7
8
/**
9
 * AttributeNotFoundException
10
 *
11
 * @package Mikemirten\Component\JsonApi\Exception
12
 */
13
class AttributeNotFoundException extends DocumentException
14
{
15
    /**
16
     * Name of not found attribute
17
     *
18
     * @var string
19
     */
20
    protected $name;
21
22
    /**
23
     * Resource inside of which an attribute has not been found
24
     *
25
     * @var ResourceObject
26
     */
27
    protected $resource;
28
29
    /**
30
     * AttributeNotFoundException constructor.
31
     *
32
     * @param ResourceObject  $resource
33
     * @param string          $name
34
     * @param \Exception|null $previous
35
     */
36 2
    public function __construct(ResourceObject $resource, string $name, \Exception $previous = null)
37
    {
38 2
        $this->name     = $name;
39 2
        $this->resource = $resource;
40
41 2
        $message = sprintf('Attribute "%s" not found inside of [%s].', $name, $resource);
42
43 2
        parent::__construct($message, 0, $previous);
44 2
    }
45
46
    /**
47
     * Get name of not found attribute
48
     *
49
     * @return string
50
     */
51 1
    public function getName(): string
52
    {
53 1
        return $this->name;
54
    }
55
56
    /**
57
     * Get resource inside of which an attribute has not been found
58
     *
59
     * @return ResourceObject
60
     */
61 1
    public function getResource(): ResourceObject
62
    {
63 1
        return $this->resource;
64
    }
65
}