HEX
Server: Apache/2.4.65 (Debian)
System: Linux 88f31f35b0b8 6.1.0-38-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.147-1 (2025-08-02) x86_64
User: www-data (33)
PHP: 8.2.29
Disabled: NONE
Upload Files
File: /var/www/html/wp-content/plugins/wp-rss-aggregator/v4/src/Query/AbstractWpQueryIterator.php
<?php

namespace RebelCode\Wpra\Core\Query;

use Iterator;
use WP_Post;

/**
 * Abstract implementation of a WP Query iterator.
 *
 * @since 4.13
 */
abstract class AbstractWpQueryIterator implements Iterator
{
    /**
     * The queried posts.
     *
     * @since 4.13
     *
     * @var WP_Post[]
     */
    protected $posts;

    /**
     * Retrieves the WordPress query args.
     *
     * @since 4.13
     *
     * @return array
     */
    abstract protected function getQueryArgs();

    /**
     * {@inheritdoc}
     *
     * @since 4.13
     */
    public function rewind()
    {
        $this->posts = get_posts($this->getQueryArgs());
        reset($this->posts);
    }

    /**
     * {@inheritdoc}
     *
     * @since 4.13
     */
    public function next()
    {
        next($this->posts);
    }

    /**
     * {@inheritdoc}
     *
     * @since 4.13
     */
    public function key()
    {
        return key($this->posts);
    }

    /**
     * {@inheritdoc}
     *
     * @since 4.13
     */
    public function current()
    {
        return current($this->posts);
    }

    /**
     * {@inheritdoc}
     *
     * @since 4.13
     */
    public function valid()
    {
        return key($this->posts) !== null;
    }
}