Passed
Pull Request — main (#6)
by Viktor
35:45 queued 27:24
created

Email::getMessage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
c 0
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
declare(strict_types=1);
3
4
namespace PrinsFrank\PhpStrictModels\Rule;
5
6
use Attribute;
7
use PrinsFrank\PhpStrictModels\Enum\Type;
8
9
#[Attribute]
10
class Email implements Rule
11
{
12
    /** @return Type[] */
13 1
    public function applicableToTypes(): array
14
    {
15 1
        return [Type::string];
16
    }
17
18
    /** @param string $value */
19 1
    public function isValid(mixed $value): bool
20
    {
21 1
        return filter_var($value, FILTER_VALIDATE_EMAIL) !== false;
22
    }
23
24 1
    public function getMessage(): string
25
    {
26 1
        return 'Should be a valid email address';
27
    }
28
}
29