public function getBatches($size = null)
 {
     $items = $this->results;
     $mapFn = $this->toBatchFn;
     if ($size) {
         $items = \Aws\partition(\Aws\flatmap($items, $mapFn), $size);
         $mapFn = function ($resources) {
             return new Batch($this->client, $this->type, $resources);
         };
     }
     return \Aws\map($items, $mapFn);
 }
 /**
  * Support for opendir().
  *
  * The opendir() method of the Amazon S3 stream wrapper supports a stream
  * context option of "listFilter". listFilter must be a callable that
  * accepts an associative array of object data and returns true if the
  * object should be yielded when iterating the keys in a bucket.
  *
  * @param string $path    The path to the directory
  *                        (e.g. "s3://dir[</prefix>]")
  * @param string $options Unused option variable
  *
  * @return bool true on success
  * @see http://www.php.net/manual/en/function.opendir.php
  */
 public function dir_opendir($path, $options)
 {
     $this->openedPath = $path;
     $params = $this->withPath($path);
     $delimiter = $this->getOption('delimiter');
     /** @var callable $filterFn */
     $filterFn = $this->getOption('listFilter');
     $op = ['Bucket' => $params['Bucket']];
     $this->openedBucket = $params['Bucket'];
     if ($delimiter === null) {
         $delimiter = '/';
     }
     if ($delimiter) {
         $op['Delimiter'] = $delimiter;
     }
     if ($params['Key']) {
         $params['Key'] = rtrim($params['Key'], $delimiter) . $delimiter;
         $op['Prefix'] = $params['Key'];
     }
     $this->openedBucketPrefix = $params['Key'];
     // Filter our "/" keys added by the console as directories, and ensure
     // that if a filter function is provided that it passes the filter.
     $this->objectIterator = \Aws\flatmap($this->getClient()->getPaginator('ListObjects', $op), function (Result $result) use($filterFn) {
         $contentsAndPrefixes = $result->search('[Contents[], CommonPrefixes[]][]');
         // Filter out dir place holder keys and use the filter fn.
         return array_filter($contentsAndPrefixes, function ($key) use($filterFn) {
             return (!$filterFn || call_user_func($filterFn, $key)) && (!isset($key['Key']) || substr($key['Key'], -1, 1) !== '/');
         });
     });
     return true;
 }