GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmailChecker   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 34
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
A isValid() 0 14 3
1
<?php
2
3
/*
4
 * This file is part of the EmailChecker package.
5
 *
6
 * (c) Matthieu Moquet <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace EmailChecker;
13
14
use EmailChecker\Adapter\AdapterInterface;
15
use EmailChecker\Adapter\BuiltInAdapter;
16
use EmailChecker\Exception\InvalidEmailException;
17
18
/**
19
 * Checks throwaway email.
20
 *
21
 * @author Matthieu Moquet <[email protected]>
22
 */
23
class EmailChecker
24
{
25
    protected $adapter;
26
27
    /**
28
     * @param AdapterInterface $adapter Checker adapter
29
     */
30
    public function __construct(AdapterInterface $adapter = null)
31
    {
32
        $this->adapter = $adapter ?: new BuiltInAdapter();
33
    }
34
35
    /**
36
     * Check if it's a valid email, ie. not a throwaway email.
37
     *
38
     * @param string $email The email to check
39
     *
40
     * @return bool true for a throwaway email
41
     */
42
    public function isValid($email)
43
    {
44
        if (false === $email = filter_var($email, FILTER_VALIDATE_EMAIL)) {
45
            return false;
46
        }
47
48
        try {
49
            list($local, $domain) = Utilities::parseEmailAddress($email);
0 ignored issues
show
Unused Code introduced by
The assignment to $local is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
50
        } catch (InvalidEmailException $e) {
51
            return false;
52
        }
53
54
        return !$this->adapter->isThrowawayDomain($domain);
55
    }
56
}
57