Completed
Pull Request — master (#6)
by Patrick
02:25
created

UserTest::testEmailFunction()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 9.4285
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
Best Practice introduced by
The function validEmail() has been defined more than once; this definition is ignored, only the first definition in api/v1/users.php (L63-80) is considered.

This check looks for functions that have already been defined in other files.

Some Codebases, like WordPress, make a practice of defining functions multiple times. This may lead to problems with the detection of function parameters and types. If you really need to do this, you can mark the duplicate definition with the @ignore annotation.

/**
 * @ignore
 */
function getUser() {

}

function getUser($id, $realm) {

}

See also the PhpDoc documentation for @ignore.

Loading history...
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