ankitjain28may /
openchat
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
|
0 ignored issues
–
show
|
|||
| 2 | |||
| 3 | namespace ChatApp; |
||
| 4 | require_once (dirname(__DIR__) . '/config/database.php'); |
||
| 5 | |||
| 6 | /** |
||
| 7 | * For checking online status |
||
| 8 | */ |
||
| 9 | class Online |
||
| 10 | { |
||
| 11 | |||
| 12 | View Code Duplication | public static function setOnlineStatus($userId) |
|
|
0 ignored issues
–
show
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...
|
|||
| 13 | { |
||
| 14 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
||
| 15 | $query = "Update login set login_status = 1 where login_id = '$userId'"; |
||
| 16 | if(!$connect->query($query)); |
||
| 17 | echo $connect->error; |
||
| 18 | $connect->close(); |
||
| 19 | } |
||
| 20 | |||
| 21 | View Code Duplication | public static function removeOnlineStatus($userId) |
|
|
0 ignored issues
–
show
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...
|
|||
| 22 | { |
||
| 23 | $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME); |
||
| 24 | $query = "Update login set login_status = 0 where login_id = '$userId'"; |
||
| 25 | if(!$connect->query($query)); |
||
| 26 | echo $connect->error; |
||
| 27 | $connect->close(); |
||
| 28 | } |
||
| 29 | } |
||
| 30 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.