Test Failed
Push — master ( 2dd2d2...d1b72a )
by Anatoly
02:55
created

ResourceNotFoundException::assert()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace App\Exception;
4
5
/**
6
 * ResourceNotFoundException
7
 */
8
final class ResourceNotFoundException extends AbstractException
9
{
10
11
    /**
12
     * Constructor of the class
13
     *
14
     * @param null|string $message
15
     */
16
    public function __construct(string $message = null)
17
    {
18
        parent::__construct($message ?? 'The requested resource was not found');
19
    }
20
21
    /**
22
     * Throws the exception if the given entity is NULL
23
     *
24
     * @param null|object $entity
25
     *
26
     * @return void
27
     *
28
     * @throws self
29
     */
30
    public static function assert(?object $entity) : void
31
    {
32
        if (null === $entity) {
33
            throw new self($entity, $violations);
0 ignored issues
show
Unused Code introduced by
The call to App\Exception\ResourceNo...xception::__construct() has too many arguments starting with $violations. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

33
            throw /** @scrutinizer ignore-call */ new self($entity, $violations);

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
Comprehensibility Best Practice introduced by
The variable $violations seems to be never defined.
Loading history...
34
        }
35
    }
36
}
37