BasicValidator::validate()   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
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace EmailValidator\Validator;
6
7
use EmailValidator\EmailAddress;
8
9
/**
10
 * Validates the basic format of an email address
11
 *
12
 * This validator checks if the email address follows the basic format requirements
13
 * using PHP's built-in filter_var function with FILTER_VALIDATE_EMAIL.
14
 */
15
class BasicValidator extends AValidator
16
{
17
    /**
18
     * Validates the basic format of an email address
19
     *
20
     * @param EmailAddress $email The email address to validate
21
     * @return bool True if the email address has a valid format, false otherwise
22
     */
23
    public function validate(EmailAddress $email): bool
24
    {
25
        return (bool) filter_var($email->getEmailAddress(), FILTER_VALIDATE_EMAIL);
26
    }
27
}
28