getRecNameFromFriendRequest()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 8
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
rs 10
1
<?php
2
function getAllPendingFriendRequests($useranme, $connection) {
3
        $stmt = $connection->prepare("SELECT * FROM friends WHERE reciever = ? AND status = 'p'");
4
        $stmt->bind_param("s", $useranme);
5
        $stmt->execute();
6
    $result = $stmt->get_result();
7
    $user = $result->fetch_assoc();
8
    if($result->num_rows === 0) return('You have no incoming friend requests.');
9
    $stmt->close();
10
11
    return $user;
12
}
13
14
function getSendNameFromFriendRequest($id, $connection) {
15
    $stmt = $connection->prepare("SELECT sender FROM friends WHERE id = ?");
16
    $stmt->bind_param("s", $id);
17
    $stmt->execute();
18
    $result = $stmt->get_result();
19
    while($row = $result->fetch_assoc()) {
20
        $sender = $row['sender'];
21
    }
22
    return $sender;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $sender does not seem to be defined for all execution paths leading up to this point.
Loading history...
23
    $stmt->close();
0 ignored issues
show
Unused Code introduced by
$stmt->close() is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
24
}
25
26
function getRecNameFromFriendRequest($id, $connection) {
27
    $stmt = $connection->prepare("SELECT reciever FROM friends WHERE id = ?");
28
    $stmt->bind_param("s", $id);
29
    $stmt->execute();
30
    $result = $stmt->get_result();
31
    while($row = $result->fetch_assoc()) {
32
        $rec = $row['reciever'];
33
    }
34
    return $rec;
0 ignored issues
show
Comprehensibility Best Practice introduced by
The variable $rec does not seem to be defined for all execution paths leading up to this point.
Loading history...
35
    $stmt->close();
0 ignored issues
show
Unused Code introduced by
$stmt->close() is not reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
36
}
37
?>
0 ignored issues
show
Best Practice introduced by
It is not recommended to use PHP's closing tag ?> in files other than templates.

Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore.

A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever.

Loading history...