CommentQuery.php 5.42 KB
<?php

namespace FootyRoom\Queries\Comment;

/**
 * Query to return comments in a discussion.
 */
class CommentQuery implements WithUserQuery
{
    use ViewedBy;
    use WithUser;

    /**
     * @var string
     */
    protected $discussionId;

    /**
     * Specifies ids of comments to fetch.
     *
     * @var int[]
     */
    protected $ids;

    /**
     * Should show unpublished comments?
     *
     * @var bool
     */
    protected $unpublished;

    /**
     * Optional comment meta keys to return.
     *
     * @var string[]
     */
    protected $meta = [];

    /**
     * @var string
     */
    protected $filter;

    /**
     * @var int
     */
    protected $limit = 20;

    /**
     * @var int
     */
    protected $offset = 0;

    /**
     * Query comments only older than specific one.
     *
     * This is used as the initial cursor starting position to facilitate paging
     * for DESC ordering in rapidly changing data set.
     *
     * @var int
     */
    protected $sinceId = 0;

    /**
     * @var string
     */
    protected $order = 'desc';

    /**
     * @var bool
     */
    protected $threaded = true;

    /**
     * Searches for comments in the same thread as specified comment id. Only
     * parent and sibling comments are returned.
     *
     * @var int
     */
    protected $threadOf = 0;

    /**
     * Returns comments without specified comment.
     *
     * @var int
     */
    protected $without = 0;

    /**
     * Constructor.
     *
     * @param string $discussionId
     */
    public function __construct($discussionId = null)
    {
        $this->discussionId = $discussionId;
    }

    /**
     * Sets the value of ids.
     *
     * @param array $ids
     *
     * @return self
     */
    public function ids(array $ids)
    {
        $this->ids = $ids;

        return $this;
    }

    /**
     * Gets value of ids.
     *
     * @return int
     */
    public function getIds()
    {
        return $this->ids;
    }

    /**
     * Gets the value of order.
     *
     * @return string
     */
    public function getOrder()
    {
        return $this->order;
    }

    /**
     * Sets the value of order.
     *
     * @param string $order the order
     *
     * @return self
     */
    public function order($order)
    {
        $this->order = $order;

        return $this;
    }

    /**
     * Gets the value of discussionId.
     *
     * @return string
     */
    public function getDiscussionId()
    {
        return $this->discussionId;
    }

    /**
     * Gets the Should show unpublished comments?.
     *
     * @return bool
     */
    public function getUnpublished()
    {
        return $this->unpublished;
    }

    /**
     * Gets the Optional comment meta keys to return.
     *
     * @return string[]
     */
    public function getMeta()
    {
        return $this->meta;
    }

    /**
     * Gets the value of filter.
     *
     * @return string
     */
    public function getFilter()
    {
        return $this->filter;
    }

    /**
     * Sets the value of filter.
     *
     * @param string $filter the filter
     *
     * @return self
     */
    public function filter($filter)
    {
        $this->filter = $filter;

        return $this;
    }

    /**
     * Gets the value of limit.
     *
     * @return int
     */
    public function getLimit()
    {
        return $this->limit;
    }

    /**
     * Sets the value of limit.
     *
     * @param int $limit the limit
     *
     * @return self
     */
    public function limit($limit)
    {
        $this->limit = $limit;

        return $this;
    }

    /**
     * Gets the value of offset.
     *
     * @return int
     */
    public function getOffset()
    {
        return $this->offset;
    }

    /**
     * Sets the value of offset.
     *
     * @param int $offset the offset
     *
     * @return self
     */
    public function offset($offset)
    {
        $this->offset = $offset;

        return $this;
    }

    /**
     * Gets the value of sinceId.
     *
     * @return int
     */
    public function getSinceId()
    {
        return $this->sinceId;
    }

    /**
     * Sets the value of sinceId.
     *
     * @param int $sinceId the since id
     *
     * @return self
     */
    public function sinceId($sinceId)
    {
        $this->sinceId = $sinceId;

        return $this;
    }

    /**
     * Gets the value of threaded.
     *
     * @return bool
     */
    public function getThreaded()
    {
        return $this->threaded;
    }

    /**
     * Sets the value of threaded.
     *
     * @param bool $threaded the threaded
     *
     * @return self
     */
    public function threaded($threaded)
    {
        $this->threaded = $threaded;

        return $this;
    }

    /**
     * Gets the threadOf.
     *
     * @return int
     */
    public function getThreadOf()
    {
        return $this->threadOf;
    }

    /**
     * Sets the value of threadOf.
     *
     * @param int $commentId
     *
     * @return self
     */
    public function threadOf($commentId)
    {
        $this->threadOf = $commentId;

        return $this;
    }

    /**
     * Gets the without value.
     *
     * @return int
     */
    public function getWithout()
    {
        return $this->without;
    }

    /**
     * Sets the without value.
     *
     * @param int $commentId
     *
     * @return self
     */
    public function without($commentId)
    {
        $this->without = $commentId;

        return $this;
    }
}