Passed
Push — master ( 5f9e30...9e7e6b )
by Dedipyaman
02:07
created

EmailValidator::getResult()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 5
nc 2
nop 2
dl 0
loc 10
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Phypes\Validator;
5
6
use Phypes\Error\TypeError\TypeError;
7
use Phypes\Error\TypeError\TypeErrorCode;
8
use Phypes\Result;
9
use Phypes\Rule\MinimumLength;
0 ignored issues
show
Bug introduced by
The type Phypes\Rule\MinimumLength was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
11
class EmailValidator extends AbstractValidator
12
{
13
    public function getResult($email, $options = []): Result
14
    {
15
        $this->validated = true;
16
17
        if (filter_var($email, FILTER_VALIDATE_EMAIL)) {
18
            return $this->success();
19
        }
20
21
        $errors = new TypeError(TypeErrorCode::EMAIL_INVALID, 'The provided email is invalid.');
22
        return $this->failure($errors);
23
    }
24
25
}