Habari\Comments::delete_these PHP Method

delete_these() public static method

Deletes comments from the database
public static delete_these ( $comments ) : boolean
return boolean True on success, false on failure
    public static function delete_these($comments)
    {
        if (!is_array($comments) && !$comments instanceof Comments) {
            $comments = array($comments);
        }
        if (count($comments) == 0) {
            return true;
        }
        if ($comments instanceof Comments) {
            // Delete all the comments directly
            $result = $comments->delete();
        } else {
            if (is_array($comments)) {
                // We have an array... of something
                if ($comments[0] instanceof Comment) {
                    $result = true;
                    /** @var Comment $comment */
                    foreach ($comments as $comment) {
                        $comment_result = $comment->delete();
                        if (!$comment_result) {
                            $result = false;
                        }
                    }
                } else {
                    if (is_numeric($comments[0])) {
                        // We were passed an array of ID's. Get their objects and delete them.
                        /** @var Comments $comments */
                        $comments = self::get(array('id' => $comments));
                        $result = $comments->delete();
                    } else {
                        $result = false;
                    }
                }
            } else {
                // We were passed a type we could not understand.
                $result = false;
            }
        }
        return $result;
    }