DateTime::process()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
3
namespace Faulancer\Form\Validator\Base;
4
5
use Faulancer\Form\Validator\AbstractValidator;
6
7
/**
8
 * Class DateTime | DateTime.php
9
 * @package Faulancer\Form\Validator\Base
10
 * @author Florian Knapp <[email protected]>
11
 */
12
class DateTime extends AbstractValidator
13
{
14
15
    /**
16
     * The error message as key for translation
17
     * @var string
18
     */
19
    protected $errorMessage = 'validator_invalid_datetime_format';
20
21
    /**
22
     * Proof date validation with the \DateTime object
23
     *
24
     * @param string $data
25
     *
26
     * @return bool
27
     */
28
    public function process($data)
29
    {
30
        try {
31
            $date = new \DateTime($data);
0 ignored issues
show
Unused Code introduced by
$date is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
32
            return true;
33
        } catch (\Exception $e) {
34
            return false;
35
        }
36
37
    }
38
39
}