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: use Guzzle\Common\Exception\InvalidArgumentException;
 6: 
 7: /**
 8:  * Filters values using a callback
 9:  *
10:  * Used when PHP 5.4's {@see \CallbackFilterIterator} is not available
11:  */
12: class FilterIterator extends \FilterIterator
13: {
14:     /**
15:      * @var mixed Callback used for filtering
16:      */
17:     protected $callback;
18: 
19:     /**
20:      * @param \Traversable   $iterator Traversable iterator
21:      * @param array|\Closure $callback Callback used for filtering. Return true to keep or false to filter.
22:      *
23:      * @throws InvalidArgumentException if the callback if not callable
24:      */
25:     public function __construct(\Traversable $iterator, $callback)
26:     {
27:         parent::__construct($iterator);
28:         if (!is_callable($callback)) {
29:             throw new InvalidArgumentException('The callback must be callable');
30:         }
31:         $this->callback = $callback;
32:     }
33: 
34:     /**
35:      * {@inheritdoc}
36:      */
37:     public function accept()
38:     {
39:         return call_user_func($this->callback, $this->current());
40:     }
41: }
42: 
php-coveralls API documentation generated by ApiGen 2.8.0