Conditions | 1 |
Paths | 1 |
Total Lines | 10 |
Code Lines | 8 |
Lines | 10 |
Ratio | 100 % |
Changes | 0 |
1 | <?php |
||
14 | View Code Duplication | public function getId($databaseName, $username) |
|
|
|||
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 |
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.