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

  • CustomFilterIterator
  • DateRangeFilterIterator
  • DepthRangeFilterIterator
  • ExcludeDirectoryFilterIterator
  • FilecontentFilterIterator
  • FilenameFilterIterator
  • FilePathsIterator
  • FileTypeFilterIterator
  • FilterIterator
  • MultiplePcreFilterIterator
  • PathFilterIterator
  • RecursiveDirectoryIterator
  • SizeRangeFilterIterator
  • SortableIterator
  • Overview
  • Namespace
  • Class
  • Tree
  • Todo
 1: <?php
 2: 
 3: /*
 4:  * This file is part of the Symfony package.
 5:  *
 6:  * (c) Fabien Potencier <fabien@symfony.com>
 7:  *
 8:  * For the full copyright and license information, please view the LICENSE
 9:  * file that was distributed with this source code.
10:  */
11: 
12: namespace Symfony\Component\Finder\Iterator;
13: 
14: /**
15:  * CustomFilterIterator filters files by applying anonymous functions.
16:  *
17:  * The anonymous function receives a \SplFileInfo and must return false
18:  * to remove files.
19:  *
20:  * @author Fabien Potencier <fabien@symfony.com>
21:  */
22: class CustomFilterIterator extends FilterIterator
23: {
24:     private $filters = array();
25: 
26:     /**
27:      * Constructor.
28:      *
29:      * @param \Iterator $iterator The Iterator to filter
30:      * @param array     $filters  An array of PHP callbacks
31:      *
32:      * @throws \InvalidArgumentException
33:      */
34:     public function __construct(\Iterator $iterator, array $filters)
35:     {
36:         foreach ($filters as $filter) {
37:             if (!is_callable($filter)) {
38:                 throw new \InvalidArgumentException('Invalid PHP callback.');
39:             }
40:         }
41:         $this->filters = $filters;
42: 
43:         parent::__construct($iterator);
44:     }
45: 
46:     /**
47:      * Filters the iterator values.
48:      *
49:      * @return Boolean true if the value should be kept, false otherwise
50:      */
51:     public function accept()
52:     {
53:         $fileinfo = $this->current();
54: 
55:         foreach ($this->filters as $filter) {
56:             if (false === call_user_func($filter, $fileinfo)) {
57:                 return false;
58:             }
59:         }
60: 
61:         return true;
62:     }
63: }
64: 
php-coveralls API documentation generated by ApiGen 2.8.0