Passed
Push — message-id-validator ( 1cb5b2...07464f )
by Eduardo Gulias
02:11
created

MessageIDValidation::getWarnings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Egulias\EmailValidator\Validation;
4
5
use Egulias\EmailValidator\EmailLexer;
6
use Egulias\EmailValidator\MessageIDParser;
7
use Egulias\EmailValidator\Result\InvalidEmail;
8
use Egulias\EmailValidator\Result\Reason\ExceptionFound;
9
10
class MessageIDValidation implements EmailValidation
11
{
12 4
    public function isValid(string $email, EmailLexer $emailLexer): bool
13
    {
14 4
        $this->parser = new MessageIDParser($emailLexer);
0 ignored issues
show
Bug introduced by
The property parser does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15
        try {
16 4
            $result = $this->parser->parse($email);
17 4
            $this->warnings = $this->parser->getWarnings();
0 ignored issues
show
Bug introduced by
The property warnings does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
18 4
            if ($result->isInvalid()) {
19
                /** @psalm-suppress PropertyTypeCoercion */
20 1
                $this->error = $result;
0 ignored issues
show
Bug introduced by
The property error does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
21 4
                return false;
22
            }
23
        } catch (\Exception $invalid) {
24
            $this->error = new InvalidEmail(new ExceptionFound($invalid), '');
25
            return false;
26
        }
27
28 3
        return true;
29
    }
30
31
    public function getWarnings(): array
32
    {
33
        return [];
34
    }
35
36
    public function getError(): ?InvalidEmail
37
    {
38
        return null;
39
    }
40
}
41