Completed
Push — master ( fcf66f...4020b1 )
by Sam
02:59
created

UserRepository::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 10
Ratio 100 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 10
loc 10
rs 9.4285
cc 1
eloc 8
nc 1
nop 2
1
<?php
2
3
namespace Xtools;
4
5
class UserRepository extends Repository
6
{
7
8
    /**
9
     * Get the user's ID.
10
     * @param string $databaseName The database to query.
11
     * @param string $username The username to find.
12
     * @return int
13
     */
14 View Code Duplication
    public function getId($databaseName, $username)
0 ignored issues
show
Duplication introduced by
This method 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...
15
    {
16
        $userTable = $this->getTableName($databaseName, 'user');
17
        $sql = "SELECT user_id FROM $userTable WHERE user_name = :username LIMIT 1";
18
        $resultQuery = $this->projectsConnection->prepare($sql);
19
        $resultQuery->bindParam("username", $username);
20
        $resultQuery->execute();
21
        $userId = (int)$resultQuery->fetchColumn();
22
        return $userId;
23
    }
24
}
25