Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
CRAP | |
100.00% |
1 / 1 |
| |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
3 | |
100.00% |
1 / 1 |
|
| __construct | n/a |
0 / 0 |
n/a |
0 / 0 |
1 | |||||
| isValid | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package phpOMS\Validation\Network |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace phpOMS\Validation\Network; |
| 16 | |
| 17 | use phpOMS\Validation\ValidatorAbstract; |
| 18 | |
| 19 | /** |
| 20 | * Validate email. |
| 21 | * |
| 22 | * @package phpOMS\Validation\Network |
| 23 | * @license OMS License 2.0 |
| 24 | * @link https://jingga.app |
| 25 | * @since 1.0.0 |
| 26 | */ |
| 27 | abstract class Email extends ValidatorAbstract |
| 28 | { |
| 29 | /** |
| 30 | * Constructor. |
| 31 | * |
| 32 | * @since 1.0.0 |
| 33 | * @codeCoverageIgnore |
| 34 | */ |
| 35 | private function __construct() |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * {@inheritdoc} |
| 41 | */ |
| 42 | public static function isValid(mixed $value, array $constraints = null) : bool |
| 43 | { |
| 44 | if (\filter_var($value, \FILTER_VALIDATE_EMAIL) === false) { |
| 45 | self::$msg = 'Invalid Email by filter_var standards'; |
| 46 | self::$error = 1; |
| 47 | |
| 48 | return false; |
| 49 | } |
| 50 | |
| 51 | self::$msg = ''; |
| 52 | self::$error = 0; |
| 53 | |
| 54 | return true; |
| 55 | } |
| 56 | } |