Intraface_UserGateway::findByUsername()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 1
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 6
cp 0
crap 2
1
<?php
2
class Intraface_UserGateway
3
{
4
    protected $db;
5
6
    function __construct(DB_Sql $db)
7
    {
8
        $this->db = $db;
9
    }
10
11
    function findByUsername($id)
12
    {
13
        $result = $this->db->query('select id from user where email = "'.$id.'"');
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $result is correct as $this->db->query('select...email = "' . $id . '"') (which targets DB_Sql::query()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
Unused Code introduced by
$result is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
14
        $this->db->nextRecord();
15
        return new Intraface_User($this->db->f('id'));
16
    }
17
18
    function findById($id)
19
    {
20
        return new Intraface_User($id);
21
    }
22
23
    function getAll()
24
    {
25
        $user = new Intraface_User();
26
        return $user->getAll();
0 ignored issues
show
Bug introduced by
The method getAll() does not seem to exist on object<Intraface_User>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
27
    }
28
29
    function findByEmail($email)
0 ignored issues
show
Unused Code introduced by
The parameter $email is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
30
    {
31
        // @todo @see User::sendForgottenPassword()
32
    }
33
}
34