Implement Comment object for the get_single method

This commit is contained in:
Pierre
2018-04-21 15:31:40 +02:00
parent e20403e8ab
commit cf4b75c61a
4 changed files with 94 additions and 18 deletions

View File

@ -5,7 +5,7 @@
* @author Pierre HUBERT
*/
abstract class BaseUniqueObject {
class BaseUniqueObject {
//Private fields
private $id = 0;

View File

@ -12,11 +12,21 @@ class Comment extends BaseUniqueObject {
private $postID;
private $time_sent;
private $content;
private $image_path;
private $image_url;
private $img_path;
private $img_url;
private $likes;
private $userLike;
/**
* Public constructor
*/
public function __construct(){
//Initialize some values
$this->postID = 0;
$this->userID = 0;
$this->likes = -1;
}
//Set and get user ID
public function set_userID(int $userID){
$this->userID = $userID;
@ -31,6 +41,10 @@ class Comment extends BaseUniqueObject {
$this->postID = $postID;
}
public function has_postID() : bool {
return $this->postID > 0;
}
public function get_postID() : int {
return $this->postID;
}
@ -88,6 +102,10 @@ class Comment extends BaseUniqueObject {
$this->likes = $likes;
}
public function has_likes() : bool {
return $this->likes > -1;
}
public function get_likes() : int {
return $this->likes;
}