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
Push — master ( e1678b...c65e1e )
by Henrique
04:51
created

Email::validate()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
rs 9.2
cc 4
eloc 7
nc 4
nop 1
crap 4.0466
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
        $emailValidator = $this->getEmailValidator();
37 17
        if (!$emailValidator instanceof EmailValidator) {
38 16
            return is_string($input) && filter_var($input, FILTER_VALIDATE_EMAIL);
39
        }
40
41 1
        if (!class_exists('Egulias\\EmailValidator\\Validation\\RFCValidation')) {
42 1
            return $emailValidator->isValid($input);
43
        }
44
45
        return $emailValidator->isValid($input, new RFCValidation());
46
    }
47
}
48