These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * /classes/DomainMOD/User.php |
||
4 | * |
||
5 | * This file is part of DomainMOD, an open source domain and internet asset manager. |
||
6 | * Copyright (c) 2010-2017 Greg Chetcuti <[email protected]> |
||
7 | * |
||
8 | * Project: http://domainmod.org Author: http://chetcuti.com |
||
9 | * |
||
10 | * DomainMOD is free software: you can redistribute it and/or modify it under the terms of the GNU General Public |
||
11 | * License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later |
||
12 | * version. |
||
13 | * |
||
14 | * DomainMOD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied |
||
15 | * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. |
||
16 | * |
||
17 | * You should have received a copy of the GNU General Public License along with DomainMOD. If not, see |
||
18 | * http://www.gnu.org/licenses/. |
||
19 | * |
||
20 | */ |
||
21 | //@formatter:off |
||
22 | namespace DomainMOD; |
||
23 | |||
24 | class User |
||
25 | { |
||
26 | public $system; |
||
27 | |||
28 | public function __construct() |
||
29 | { |
||
30 | $this->system = new System(); |
||
31 | } |
||
32 | |||
33 | public function getAdminId() |
||
34 | { |
||
35 | $pdo = $this->system->db(); |
||
36 | |||
37 | $stmt = $pdo->query(" |
||
38 | SELECT id |
||
39 | FROM users |
||
40 | WHERE username = 'admin'"); |
||
41 | return $stmt->fetchColumn(); |
||
42 | } |
||
43 | |||
44 | View Code Duplication | public function getFullName($user_id) |
|
1 ignored issue
–
show
|
|||
45 | { |
||
46 | $pdo = $this->system->db(); |
||
47 | |||
48 | $stmt = $pdo->prepare(" |
||
49 | SELECT first_name, last_name |
||
50 | FROM users |
||
51 | WHERE id = :user_id"); |
||
52 | $stmt->bindValue('user_id', $user_id, \PDO::PARAM_INT); |
||
53 | $stmt->execute(); |
||
54 | $result = $stmt->fetch(); |
||
55 | |||
56 | return $result->first_name . ' ' . $result->last_name; |
||
57 | } |
||
58 | |||
59 | } //@formatter:on |
||
60 |
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.