BasicValidator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 2
dl 0
loc 11
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validate() 0 3 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