EntityNotFoundException   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 51
c 0
b 0
f 0
wmc 3
lcom 0
cbo 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getModel() 0 4 1
A getId() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Rinvex\Repository\Exceptions;
6
7
use RuntimeException;
8
9
class EntityNotFoundException extends RuntimeException
10
{
11
    /**
12
     * Id of the affected model.
13
     *
14
     * @var string
15
     */
16
    protected $id;
17
18
    /**
19
     * Name of the affected model.
20
     *
21
     * @var string
22
     */
23
    protected $model;
24
25
    /**
26
     * Set the affected model.
27
     *
28
     * @param string $model
29
     * @param int    $id
30
     *
31
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
32
     */
33
    public function __construct($model, $id)
34
    {
35
        $this->id = $id;
0 ignored issues
show
Documentation Bug introduced by
The property $id was declared of type string, but $id is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
36
        $this->model = $model;
37
        $this->message = "No results for model [{$model}] #{$id}.";
38
    }
39
40
    /**
41
     * Get the affected model.
42
     *
43
     * @return string
44
     */
45
    public function getModel(): string
46
    {
47
        return $this->model;
48
    }
49
50
    /**
51
     * Get the affected model Id.
52
     *
53
     * @return string
54
     */
55
    public function getId(): string
56
    {
57
        return $this->id;
58
    }
59
}
60