Completed
Push — master ( bf23bc...4f23d4 )
by Patrick
06:42
created

UserTest.php ➔ validEmail()   A

Complexity

Conditions 4
Paths 4

Size

Total Lines 18
Code Lines 10

Duplication

Lines 18
Ratio 100 %

Importance

Changes 0
Metric Value
cc 4
eloc 10
nc 4
nop 1
dl 18
loc 18
rs 9.2
c 0
b 0
f 0
1
<?php
2
//require_once(dirname(__FILE__).'/../api/v1/users.php');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
3
4 View Code Duplication
function validEmail($email)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
5
{
6
    if(filter_var($email) === false)
7
    {
8
        return false;
9
    }
10
    $pos = strpos($email, '@');
11
    if($pos === false)
12
    {
13
        return false;
14
    }
15
    $domain = substr($email, $pos+1);
16
    if(checkdnsrr($domain, 'MX') === false)
17
    {
18
        return false;
19
    }
20
    return true;
21
}
22
23
class UserTest extends PHPUnit_Framework_TestCase
24
{
25
    public function testEmailFunction()
26
    {
27
        $this->assertTrue(validEmail('[email protected]'));
28
        $this->assertFalse(validEmail('test@test'));
29
        $this->assertFalse(validEmail('[email protected]'));
30
    }
31
}
32
/* vim: set tabstop=4 shiftwidth=4 expandtab: */
33