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:  * Batch transfer strategy where transfer logic can be defined via a Closure.
 9:  * This class is to be used with {@see Guzzle\Batch\BatchInterface}
10:  */
11: class BatchClosureTransfer implements BatchTransferInterface
12: {
13:     /**
14:      * @var callable A closure that performs the transfer
15:      */
16:     protected $callable;
17: 
18:     /**
19:      * @var mixed $context Context passed to the callable
20:      */
21:     protected $context;
22: 
23:     /**
24:      * Constructor used to specify the closure for performing the transfer
25:      *
26:      * @param mixed $callable Callable that performs the transfer. This function should accept two arguments:
27:      *                        (array $batch, mixed $context).
28:      * @param mixed $context  Optional context to pass to the batch divisor
29:      *
30:      * @throws InvalidArgumentException
31:      */
32:     public function __construct($callable, $context = null)
33:     {
34:         if (!is_callable($callable)) {
35:             throw new InvalidArgumentException('Argument must be callable');
36:         }
37: 
38:         $this->callable = $callable;
39:         $this->context = $context;
40:     }
41: 
42:     /**
43:      * {@inheritDoc}
44:      */
45:     public function transfer(array $batch)
46:     {
47:         return empty($batch) ? null : call_user_func($this->callable, $batch, $this->context);
48:     }
49: }
50: 
php-coveralls API documentation generated by ApiGen 2.8.0