Profile   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 37
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getProfile() 0 18 2
1
<?php
2
/**
3
 * Profile Class Doc Comment
4
 *
5
 * PHP version 5
6
 *
7
 * @category PHP
8
 * @package  OpenChat
9
 * @author   Ankit Jain <[email protected]>
10
 * @license  The MIT License (MIT)
11
 * @link     https://github.com/ankitjain28may/openchat
12
 */
13
namespace ChatApp;
14
15
require_once dirname(__DIR__).'/vendor/autoload.php';
16
use mysqli;
17
use Dotenv\Dotenv;
18
$dotenv = new Dotenv(dirname(__DIR__));
19
$dotenv->load();
20
21
22
/**
23
 * For retreiving User Profile
24
 *
25
 * @category PHP
26
 * @package  OpenChat
27
 * @author   Ankit Jain <[email protected]>
28
 * @license  The MIT License (MIT)
29
 * @link     https://github.com/ankitjain28may/openchat
30
 */
31
class Profile
32
{
33
    /*
34
    |--------------------------------------------------------------------------
35
    | Profile Class
36
    |--------------------------------------------------------------------------
37
    |
38
    | Send message to other user.
39
    |
40
    */
41
42
    /**
43
     * To get User Profile
44
     *
45
     * @param string $userId To store userId
46
     *
47
     * @return array / null
48
     */
49
    public static function getProfile($userId)
50
    {
51
        $connect = new mysqli(
52
            getenv('DB_HOST'),
53
            getenv('DB_USER'),
54
            getenv('DB_PASSWORD'),
55
            getenv('DB_NAME')
56
        );
57
        $query = "SELECT * from profile where login_id = '$userId'";
58
        $result = $connect->query($query);
59
        if ($result->num_rows > 0) {
60
            // if true
61
            $details = $result->fetch_assoc();
62
            return $details;
63
        } else {
64
            return null;
65
        }
66
    }
67
}
68