Completed
Pull Request — master (#5)
by Brent
13:30
created

FutureDate   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 21
loc 21
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A passes() 6 6 1
A message() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
namespace Spatie\ValidationRules\Rules;
4
5
use Illuminate\Contracts\Validation\Rule;
6
use Spatie\ValidationRules\IsDateRule;
7
8 View Code Duplication
class FutureDate implements Rule
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    use IsDateRule;
11
12
    public function __construct(string $format = 'Y-m-d')
13
    {
14
        $this->format = $format;
15
    }
16
17
    public function passes($attribute, $value): bool
18
    {
19
        $date = $this->createDate($value);
20
21
        return $date->isFuture();
22
    }
23
24
    public function message(): string
25
    {
26
        return __('validationRules.future_date');
27
    }
28
}
29