Completed
Branch master (b334d3)
by Albert
13:42 queued 03:43
created

Required::verdict()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 0
cp 0
cc 2
eloc 5
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Albert221\Validation\Rule;
6
7
use Albert221\Validation\Verdict;
8
9 6
/**
10
 * Required validates whether given value is considered as existing or not.
11 6
 */
12 6
class Required extends Rule
13
{
14 6
    protected $message = 'This field is required.';
15
16 6
    /**
17
     * {@inheritdoc}
18
     */
19
    public function verdict($value): Verdict
20
    {
21
        $passes = false;
22
23
        if (null !== $value) {
24
            $passes = true;
25
        }
26
27
        return Verdict::create($passes, $this, $value);
0 ignored issues
show
Unused Code introduced by
The call to Verdict::create() has too many arguments starting with $value.

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.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
28
    }
29
}
30