RegexRule::canSkip()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
4
namespace SolBianca\Validator\Rules;
5
6
7
use SolBianca\Validator\Interfaces\RuleInterface;
8
9
class RegexRule implements RuleInterface
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14
    public function run($value, array $input, array $args): bool
15
    {
16
        return (bool)preg_match($args[0], $value);
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function errorMessage(): string
23
    {
24
        return 'Field `{field}` was not in the correct format.';
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function canSkip(): bool
31
    {
32
        return true;
33
    }
34
}