Test Failed
Pull Request — master (#19)
by Flo
02:48
created

DateTime   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 26
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A process() 0 10 2
1
<?php
2
/**
3
 * Class DateTime | DateTime.php
4
 * @package Faulancer\Form\Validator\Base
5
 * @author Florian Knapp <[email protected]>
6
 */
7
namespace Faulancer\Form\Validator\Base;
8
9
use Faulancer\Form\Validator\AbstractValidator;
10
11
/**
12
 * Class DateTime
13
 */
14
class DateTime extends AbstractValidator
15
{
16
17
    /**
18
     * The error message as key for translation
19
     * @var string
20
     */
21
    protected $errorMessage = 'validator_invalid_datetime_format';
22
23
    /**
24
     * Proof date validation with the \DateTime object
25
     * @param string $data
26
     * @return boolean
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
}