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.
Passed
Push — master ( b04125...7e274b )
by Marco
01:38
created

NonEmpty   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 21
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 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Marcosh\PhpValidationDSL\Basic;
6
7
use Marcosh\PhpValidationDSL\Translator\Translator;
8
use function is_callable;
9
use Marcosh\PhpValidationDSL\Validation;
10
11
final class NonEmpty extends ComposingAssertion implements Validation
12
{
13
    public const EMPTY = 'non-empty.empty';
14
15
    public function __construct(?callable $errorFormatter = null)
16
    {
17
        $this->isAsAsserted = IsAsAsserted::withAssertionAndErrorFormatter(
18
            function ($data) {
19
                return !empty($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::EMPTY];
25
                }
26
        );
27
    }
28
29
    public static function withTranslator(Translator $translator): self
30
    {
31
        return self::withTranslatorAndMessage($translator, self::EMPTY);
32
    }
33
}
34