EmailRule   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 25
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A errorMessage() 0 3 1
A canSkip() 0 3 1
A run() 0 3 1
1
<?php
2
3
4
namespace SolBianca\Validator\Rules;
5
6
7
use SolBianca\Validator\Interfaces\RuleInterface;
8
9
class EmailRule implements RuleInterface
10
{
11
12
    /**
13
     * {@inheritdoc}
14
     */
15
    public function run($value, array $input, array $args): bool
16
    {
17
        return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
18
    }
19
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function errorMessage(): string
24
    {
25
        return 'Field `{field}` must be a valid email address.';
26
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    public function canSkip(): bool
32
    {
33
        return true;
34
    }
35
}