<?php
/**
 * CGBetterUploads API
 *
 * @package CGBetterUploads
 */

namespace CGBetterUploads;

/**
 * A placeholder type that represents a set of download objects.
 * Created frm a filter object and an array... this is a countable and iterable list of download objects.
 * It also supports pagination.
 */
class DownloadSet extends FilterResultset
{
    /**
     * Constructor
     *
     * @param DownloadFilter $filter The filter used to load the matches
     * @param int $totalMatches the total number of downloads that match the filter.
     * @param array $matches The matches loaded from the database.   May be <= $totalmatches
     */
    public function __construct( DownloadFilter $filter, int $totalMatches, array $matches = null)
    {
        if( is_array($matches) && count($matches) && !isset($matches[0]) && !$matches[0] instanceof Download ) {
            throw new \InvalidArgumentException('Invalid matches passed to '.__METHOD__);
        }
        parent::__construct( $filter, $totalMatches, $matches );
    }

} // class
