Overview

Namespaces

  • Contrib
    • Bundle
      • CoverallsBundle
        • Console
        • Entity
      • CoverallsV1Bundle
        • Api
        • Collector
        • Command
        • Config
        • Entity
          • Git
    • Component
      • File
      • Log
      • System
        • Git
  • Guzzle
    • Batch
      • Exception
    • Cache
    • Common
      • Exception
    • Http
      • Curl
      • Exception
      • Message
      • QueryAggregator
    • Inflection
    • Iterator
    • Log
    • Parser
      • Cookie
      • Message
      • UriTemplate
      • Url
    • Plugin
      • Async
      • Backoff
      • Cache
      • Cookie
        • CookieJar
        • Exception
      • CurlAuth
      • ErrorResponse
        • Exception
      • History
      • Log
      • Md5
      • Mock
      • Oauth
    • Service
      • Builder
      • Command
        • Factory
        • LocationVisitor
          • Request
          • Response
      • Description
      • Exception
      • Resource
    • Stream
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Config
        • Definition
          • Builder
          • Exception
        • Exception
        • Loader
        • Resource
        • Util
      • Console
        • Command
        • Formatter
        • Helper
        • Input
        • Output
        • Tester
      • EventDispatcher
        • Debug
      • Finder
        • Adapter
        • Comparator
        • Exception
        • Expression
        • Iterator
        • Shell
      • Stopwatch
      • Yaml
        • Exception

Classes

  • AppendIterator
  • ChunkedIterator
  • FilterIterator
  • MapIterator
  • MethodProxyIterator
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Iterator;
 4: 
 5: /**
 6:  * Pulls out chunks from an inner iterator and yields the chunks as arrays
 7:  */
 8: class ChunkedIterator extends \IteratorIterator
 9: {
10:     /**
11:      * @var int Size of each chunk
12:      */
13:     protected $chunkSize;
14: 
15:     /**
16:      * @var array Current chunk
17:      */
18:     protected $chunk;
19: 
20:     /**
21:      * @param \Traversable $iterator  Traversable iterator
22:      * @param int          $chunkSize Size to make each chunk
23:      */
24:     public function __construct(\Traversable $iterator, $chunkSize)
25:     {
26:         parent::__construct($iterator);
27:         $this->chunkSize = $chunkSize;
28:     }
29: 
30:     /**
31:      * {@inheritdoc}
32:      */
33:     public function rewind()
34:     {
35:         $this->next();
36:     }
37: 
38:     /**
39:      * {@inheritdoc}
40:      */
41:     public function next()
42:     {
43:         $this->chunk = array();
44:         $inner = $this->getInnerIterator();
45:         for ($i = 0; $i < $this->chunkSize && $inner->valid(); $i++) {
46:             $this->chunk[] = $inner->current();
47:             $inner->next();
48:         }
49:     }
50: 
51:     /**
52:      * {@inheritdoc}
53:      */
54:     public function current()
55:     {
56:         return $this->chunk;
57:     }
58: 
59:     /**
60:      * {@inheritdoc}
61:      */
62:     public function valid()
63:     {
64:         return !empty($this->chunk);
65:     }
66: }
67: 
php-coveralls API documentation generated by ApiGen 2.8.0