Test Setup Failed
Push — master ( a87e27...976b69 )
by Ankit
02:24
created

Profile::getProfile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 9
nc 2
nop 1
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
1
<?php
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 9 and the first side effect is on line 4.

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.

Loading history...
2
3
namespace ChatApp;
4
require_once (dirname(__DIR__) . '/config/database.php');
5
6
/**
7
* For retreiving User Profile
8
*/
9
class Profile
10
{
11
12
    public static function getProfile($userId)
13
    {
14
        $connect = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
15
        $query = "SELECT * from profile where login_id = '$userId'";
16
        $result = $connect->query($query);
17
        if($result->num_rows > 0)                   // if true
18
        {
19
            $details = $result->fetch_assoc();
20
            return $details;
21
        }
22
        else
23
        {
24
            return NULL;
25
        }
26
    }
27
}