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: use Symfony\Component\Finder\Comparator\NumberComparator;
15: 
16: /**
17:  * SizeRangeFilterIterator filters out files that are not in the given size range.
18:  *
19:  * @author Fabien Potencier <fabien@symfony.com>
20:  */
21: class SizeRangeFilterIterator extends FilterIterator
22: {
23:     private $comparators = array();
24: 
25:     /**
26:      * Constructor.
27:      *
28:      * @param \Iterator          $iterator    The Iterator to filter
29:      * @param NumberComparator[] $comparators An array of NumberComparator instances
30:      */
31:     public function __construct(\Iterator $iterator, array $comparators)
32:     {
33:         $this->comparators = $comparators;
34: 
35:         parent::__construct($iterator);
36:     }
37: 
38:     /**
39:      * Filters the iterator values.
40:      *
41:      * @return Boolean true if the value should be kept, false otherwise
42:      */
43:     public function accept()
44:     {
45:         $fileinfo = $this->current();
46:         if (!$fileinfo->isFile()) {
47:             return true;
48:         }
49: 
50:         $filesize = $fileinfo->getSize();
51:         foreach ($this->comparators as $compare) {
52:             if (!$compare->test($filesize)) {
53:                 return false;
54:             }
55:         }
56: 
57:         return true;
58:     }
59: }
60: 
php-coveralls API documentation generated by ApiGen 2.8.0