private function createRecordIterator($verb, $metadataPrefix, $from, $until, $set = null, $resumptionToken = null)
    {
        $params = array('metadataPrefix' => $metadataPrefix);

        if ($from instanceof \DateTimeInterface) {
            $params['from'] = Granularity::formatDate($from, $this->getGranularity());
        } elseif (null !== $from) {
            throw new \InvalidArgumentException(sprintf(
                '%s::%s $from parameter must be an instance of \DateTimeInterface',
                get_called_class(),
                'createRecordIterator'
            ));
        }

        if ($until instanceof \DateTimeInterface) {
            $params['until'] = Granularity::formatDate($until, $this->getGranularity());
        } elseif (null !== $until) {
            throw new \InvalidArgumentException(sprintf(
                '%s::%s $until parameter must be an instance of \DateTimeInterface',
                get_called_class(),
                'createRecordIterator'
            ));
        }

        if ($set) {
            $params['set'] = $set;
        }

        return new RecordIterator($this->client, $verb, $params, $resumptionToken);
    }