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

  • AbstractBatchDecorator
  • Batch
  • BatchBuilder
  • BatchClosureDivisor
  • BatchClosureTransfer
  • BatchCommandTransfer
  • BatchRequestTransfer
  • BatchSizeDivisor
  • ExceptionBufferingBatch
  • FlushingBatch
  • HistoryBatch
  • NotifyingBatch

Interfaces

  • BatchDivisorInterface
  • BatchInterface
  • BatchTransferInterface
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: namespace Guzzle\Batch;
 4: 
 5: use Guzzle\Common\Exception\InvalidArgumentException;
 6: 
 7: /**
 8:  * Divides batches using a callable
 9:  */
10: class BatchClosureDivisor implements BatchDivisorInterface
11: {
12:     /**
13:      * @var callable Method used to divide the batches
14:      */
15:     protected $callable;
16: 
17:     /**
18:      * @var mixed $context Context passed to the callable
19:      */
20:     protected $context;
21: 
22:     /**
23:      * @param callable $callable Method used to divide the batches. The method must accept an \SplQueue and return an
24:      *                           array of arrays containing the divided items.
25:      * @param mixed    $context  Optional context to pass to the batch divisor
26:      *
27:      * @throws InvalidArgumentException if the callable is not callable
28:      */
29:     public function __construct($callable, $context = null)
30:     {
31:         if (!is_callable($callable)) {
32:             throw new InvalidArgumentException('Must pass a callable');
33:         }
34: 
35:         $this->callable = $callable;
36:         $this->context = $context;
37:     }
38: 
39:     /**
40:      * {@inheritdoc}
41:      */
42:     public function createBatches(\SplQueue $queue)
43:     {
44:         return call_user_func($this->callable, $queue, $this->context);
45:     }
46: }
47: 
php-coveralls API documentation generated by ApiGen 2.8.0