Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

Completed
Pull Request — 1.1 (#1142)
by
unknown
03:41
created

Email::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
/*
4
 * This file is part of Respect/Validation.
5
 *
6
 * (c) Alexandre Gomes Gaigalas <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the "LICENSE.md"
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Respect\Validation\Rules;
13
14
use Egulias\EmailValidator\EmailValidator;
15
use Egulias\EmailValidator\Validation\RFCValidation;
16
17
class Email extends AbstractRule
18
{
19 19
    public function __construct(EmailValidator $emailValidator = null)
20
    {
21 19
        $this->emailValidator = $emailValidator;
0 ignored issues
show
Bug introduced by
The property emailValidator 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...
22 19
    }
23
24 19
    public function getEmailValidator()
25
    {
26 19
        if (!$this->emailValidator instanceof EmailValidator
27 19
            && class_exists('Egulias\\EmailValidator\\EmailValidator')) {
28 1
            $this->emailValidator = new EmailValidator();
29 1
        }
30
31 19
        return $this->emailValidator;
32
    }
33
34 17
    public function validate($input)
35
    {
36 17
        if (!is_scalar($input)) {
37
            return false;
38
        }
39
40 17
        $emailValidator = $this->getEmailValidator();
41 17
        if (!$emailValidator instanceof EmailValidator) {
42 16
            return is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL);
43
        }
44
45 1
        if (!class_exists('Egulias\\EmailValidator\\Validation\\RFCValidation')) {
46 1
            return $emailValidator->isValid($input);
47
        }
48
49
        return $emailValidator->isValid($input, new RFCValidation());
50
    }
51
}
52