Completed
Push — develop ( 6c1fc8...1958ec )
by Abdelrahman
02:06
created

EntityNotFoundException   A

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
/*
4
 * NOTICE OF LICENSE
5
 *
6
 * Part of the Rinvex Repository Package.
7
 *
8
 * This source file is subject to The MIT License (MIT)
9
 * that is bundled with this package in the LICENSE file.
10
 *
11
 * Package: Rinvex Repository Package
12
 * License: The MIT License (MIT)
13
 * Link:    https://rinvex.com
14
 */
15
16
namespace Rinvex\Repository\Exceptions;
17
18
use RuntimeException;
19
20
class EntityNotFoundException extends RuntimeException
21
{
22
    /**
23
     * Id of the affected model.
24
     *
25
     * @var string
26
     */
27
    protected $id;
28
29
    /**
30
     * Name of the affected model.
31
     *
32
     * @var string
33
     */
34
    protected $model;
35
36
    /**
37
     * Set the affected model.
38
     *
39
     * @param  string $model
40
     * @param  int    $id
41
     *
42
     * @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...
43
     */
44
    public function __construct($model, $id)
45
    {
46
        $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...
47
        $this->model   = $model;
48
        $this->message = "No results for model [{$model}] #{$id}.";
2 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $model instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
49
    }
50
51
    /**
52
     * Get the affected model.
53
     *
54
     * @return string
55
     */
56
    public function getModel()
57
    {
58
        return $this->model;
59
    }
60
61
    /**
62
     * Get the affected model Id.
63
     *
64
     * @return string
65
     */
66
    public function getId()
67
    {
68
        return $this->id;
69
    }
70
}
71