GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 51efb0...4d5462 )
by Marco
01:21
created

IsNull   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 22
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A withTranslator() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marcosh\PhpValidationDSL\Basic;
6
7
use Marcosh\PhpValidationDSL\Translator\Translator;
8
use Marcosh\PhpValidationDSL\Validation;
9
use function is_callable;
10
11
final class IsNull extends ComposingAssertion implements Validation
12
{
13
    public const NOT_NULL = 'is-null.not-null';
14
15
    public function __construct(?callable $errorFormatter = null)
16
    {
17
        $this->isAsAsserted = IsAsAsserted::withAssertionAndErrorFormatter(
18
            function ($data) {
19
                return null === $data;
20
            },
21
            is_callable($errorFormatter) ?
0 ignored issues
show
Bug introduced by
It seems like is_callable($errorFormat...tion(...) { /* ... */ } can also be of type null; however, parameter $errorFormatter of Marcosh\PhpValidationDSL...tionAndErrorFormatter() does only seem to accept callable, maybe add an additional type check? ( Ignorable by Annotation )

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

21
            /** @scrutinizer ignore-type */ is_callable($errorFormatter) ?
Loading history...
22
                $errorFormatter :
23
                function ($data) {
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

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

23
                function (/** @scrutinizer ignore-unused */ $data) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
24
                    return [self::NOT_NULL];
25
                }
26
        );
27
    }
28
29
    public static function withTranslator(Translator $translator): self
30
    {
31
        return new self(function ($data) use ($translator) {
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed. ( Ignorable by Annotation )

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

31
        return new self(function (/** @scrutinizer ignore-unused */ $data) use ($translator) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
32
            return [$translator->translate(self::NOT_NULL)];
33
        });
34
    }
35
}
36