user_insert   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A check_view_channel() 0 7 2
A add_view_channel() 0 5 1
A __construct() 0 2 1
A send_message() 0 9 1
1
<?php
2
3
/**
4
* @Auther: bhief
5
* @Version: 1.0
6
*
7
* Inserts user information
8
*
9
**/
10
class user_insert {
11
    public $__db;
12
13
	public function __construct($conn){
14
        $this->__db = $conn;
15
	}
16
17
    function check_view_channel($vidid, $user) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
18
        $stmt = $this->__db->prepare("SELECT * FROM channel_views WHERE viewer = :user AND channel = :vidid");
19
        $stmt->bindParam(":user", $user);
20
        $stmt->bindParam(":vidid", $vidid);
21
        $stmt->execute();
22
        if($stmt->rowCount() === 0) {
23
            $this->add_view_channel($vidid, $user);
24
        }
25
    }
26
    
27
    function add_view_channel($vidid, $user) {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
28
        $stmt = $this->__db->prepare("INSERT INTO channel_views (viewer, channel) VALUES (:user, :vidid)");
29
        $stmt->bindParam(":user", $user);
30
        $stmt->bindParam(":vidid", $vidid);
31
        $stmt->execute();
32
    }   
33
34
    function send_message($author, $subject, $to, $message, $video = "", $type = "nm") {
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
35
        $stmt = $this->__db->prepare("INSERT INTO pms (owner, subject, touser, message, video_attribute, type) VALUES (:owner, :subject, :touser, :message, :video, :type)");
36
        $stmt->bindParam(":owner", $author);
37
        $stmt->bindParam(":subject", $subject);
38
        $stmt->bindParam(":touser", $to);
39
        $stmt->bindParam(":message", $message);
40
        $stmt->bindParam(":video", $video);
41
        $stmt->bindParam(":type", $type);
42
        $stmt->execute();
43
    }   
44
}
45
46
?>
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...