Habari\Comments::only PHP Method

only() public method

Returns all of the comments from the current Comments object having the specified index for the specified field $tb = $comments->only( 'trackbacks' )
public only ( string $field, mixed $index ) : array
$field string The field on the comment that is being filtered
$index mixed The value of the field that qualifies a comment
return array an array of Comment objects of the specified type
    public function only($field, $index)
    {
        static $results = array();
        if (!isset($results[$field][$index])) {
            $result = array();
            foreach ($this as $comment) {
                if ($comment->{$field} == $index) {
                    $result[$comment->id] = $comment;
                }
            }
            $results[$field][$index] = new Comments($result);
        }
        return $results[$field][$index];
    }