當前位置: 首頁>>代碼示例>>PHP>>正文


PHP FilterIterator類代碼示例

本文整理匯總了PHP中FilterIterator的典型用法代碼示例。如果您正苦於以下問題:PHP FilterIterator類的具體用法?PHP FilterIterator怎麽用?PHP FilterIterator使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了FilterIterator類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testIterator

 /**
  * Tests the whole class.
  */
 public function testIterator()
 {
     $data = range(0, 10);
     $callback = function ($value) {
         return 0 == $value % 2;
     };
     $iterator = new FilterIterator(new \ArrayIterator($data), $callback);
     $expected = array(0 => 0, 2 => 2, 4 => 4, 6 => 6, 8 => 8, 10 => 10);
     $results = array();
     foreach ($iterator as $key => $value) {
         $results[$key] = $value;
     }
     $this->assertSame($expected, $results);
     $this->assertSame($expected, $iterator->toArray());
 }
開發者ID:JerryCR,項目名稱:php-2,代碼行數:18,代碼來源:FilterIteratorTest.php

示例2: __construct

 /**
  * Creates a FilterIterator for Zym_Navigation_Iterator_Dfs
  *
  * @param Zym_Navigation_Iterator_Dfs $iterator  iterator to iterate
  * @param bool $parentDependent  [optional] whether page should be
  *                               invisible if parent is invisible,
  *                               defaults to true
  */
 public function __construct(Zym_Navigation_Iterator_Dfs $iterator, $parentDependent = null)
 {
     parent::__construct($iterator);
     if (is_bool($parentDependent)) {
         $this->_parentDependent = $parentDependent;
     }
 }
開發者ID:BGCX262,項目名稱:zym-svn-to-git,代碼行數:15,代碼來源:Visible.php

示例3: __construct

 /**
  * Takes both a directory iterator and a file extension and only returns
  * results matching the particular extension.
  *
  * @access  public
  */
 public function __construct(DirectoryIterator $it, $ext, $whitelisted = false)
 {
     parent::__construct($it);
     $this->_it = $it;
     $this->_ext = $ext;
     $this->_whitelisted = $whitelisted;
 }
開發者ID:pixlr,項目名稱:ZCE-PHP-Cert,代碼行數:13,代碼來源:filter-extension.php

示例4: __construct

 /**
  * Constructor.
  *
  * @param \Iterator $iterator    The Iterator to filter
  * @param array     $directories An array of directories to exclude
  */
 public function __construct(\Iterator $iterator, array $directories)
 {
     foreach ($directories as $directory) {
         $this->patterns[] = '#(^|/)' . preg_quote($directory, '#') . '(/|$)#';
     }
     parent::__construct($iterator);
 }
開發者ID:kchhainarong,項目名稱:chantuchP,代碼行數:13,代碼來源:ExcludeDirectoryFilterIterator.php

示例5: accept

 /**
  * {@inheritdoc}
  */
 public function accept()
 {
     if (null === $this->status) {
         return true;
     }
     return $this->status == parent::current()->getStatus();
 }
開發者ID:amirkheirabadi,項目名稱:pagekit,代碼行數:10,代碼來源:StatusFilter.php

示例6: __construct

 /**
  * Prepares filter with the iterator and the maximum age of session
  * files we want to compare to.
  *
  * @param \Iterator $iterator   The iterator with the files we want to compare to
  * @param integer   $maximumAge The maximum age of the session files we want to load
  */
 public function __construct(\Iterator $iterator, $maximumAge)
 {
     // call parent constructor
     parent::__construct($iterator);
     // initialize the maximum age of the session files we want to load
     $this->maximumAge = $maximumAge;
 }
開發者ID:jinchunguang,項目名稱:appserver,代碼行數:14,代碼來源:SessionFilter.php

示例7: __construct

    /**
     * Constructor.
     *
     * @param \RecursiveIteratorIterator $iterator    The Iterator to filter
     * @param int                        $minDepth    The min depth
     * @param int                        $maxDepth    The max depth
     */
    public function __construct(\RecursiveIteratorIterator $iterator, $minDepth = 0, $maxDepth = INF)
    {
        $this->minDepth = $minDepth;
        $iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);

        parent::__construct($iterator);
    }
開發者ID:Robert-Xie,項目名稱:php-framework-benchmark,代碼行數:14,代碼來源:DepthRangeFilterIterator.php

示例8: __construct

 /**
  * @param \Iterator                  $sourceIterator  Iterator to wrap and filter
  * @param \Iterator                  $targetIterator  Iterator used to compare against the source iterator
  * @param FilenameConverterInterface $sourceConverter Key converter to convert source to target keys
  * @param FilenameConverterInterface $targetConverter Key converter to convert target to source keys
  */
 public function __construct(\Iterator $sourceIterator, \Iterator $targetIterator, FilenameConverterInterface $sourceConverter, FilenameConverterInterface $targetConverter)
 {
     $this->targetIterator = $targetIterator;
     $this->sourceConverter = $sourceConverter;
     $this->targetConverter = $targetConverter;
     parent::__construct($sourceIterator);
 }
開發者ID:kirkov,項目名稱:backwpup,代碼行數:13,代碼來源:ChangedFilesIterator.php

示例9: foreach

 function __construct(\Iterator $iterator, array $filters)
 {
     foreach ($filters as $filter) {
         $this->filters[] = $filter;
     }
     parent::__construct($iterator);
 }
開發者ID:florinmatthew,項目名稱:find-file-content,代碼行數:7,代碼來源:FileExtensionIterator.php

示例10: __construct

 /**
  * Constructor.
  *
  * @param \RecursiveIteratorIterator $iterator    The Iterator to filter
  * @param array                      $comparators An array of \NumberComparator instances
  */
 public function __construct(\RecursiveIteratorIterator $iterator, array $comparators)
 {
     $minDepth = 0;
     $maxDepth = INF;
     foreach ($comparators as $comparator) {
         switch ($comparator->getOperator()) {
             case '>':
                 $minDepth = $comparator->getTarget() + 1;
                 break;
             case '>=':
                 $minDepth = $comparator->getTarget();
                 break;
             case '<':
                 $maxDepth = $comparator->getTarget() - 1;
                 break;
             case '<=':
                 $maxDepth = $comparator->getTarget();
                 break;
             default:
                 $minDepth = $maxDepth = $comparator->getTarget();
         }
     }
     $this->minDepth = $minDepth;
     $iterator->setMaxDepth(INF === $maxDepth ? -1 : $maxDepth);
     parent::__construct($iterator);
 }
開發者ID:faridos,項目名稱:ServerGroveLiveChat,代碼行數:32,代碼來源:DepthRangeFilterIterator.php

示例11:

 function __construct(array $ignore, $path, $it, $role)
 {
     $this->ignore = $ignore;
     $this->path = $path;
     $this->role = $role;
     parent::__construct($it);
 }
開發者ID:peopleplan,項目名稱:Pyrus,代碼行數:7,代碼來源:Filter.php

示例12: __construct

 /**
  * Create an instance of the locator iterator
  *
  * Expects either a directory, or a DirectoryIterator (or its recursive variant)
  * instance.
  *
  * @param  string|DirectoryIterator $dirOrIterator
  */
 public function __construct($dirOrIterator = '.')
 {
     if (is_string($dirOrIterator)) {
         if (!is_dir($dirOrIterator)) {
             throw new InvalidArgumentException('Expected a valid directory name');
         }
         $dirOrIterator = new RecursiveDirectoryIterator($dirOrIterator);
     }
     if (!$dirOrIterator instanceof DirectoryIterator) {
         throw new InvalidArgumentException('Expected a DirectoryIterator');
     }
     if ($dirOrIterator instanceof RecursiveIterator) {
         $iterator = new RecursiveIteratorIterator($dirOrIterator);
     } else {
         $iterator = $dirOrIterator;
     }
     parent::__construct($iterator);
     $this->setInfoClass('Zend_File_PhpClassFile');
     // Forward-compat with PHP 5.3
     if (version_compare(PHP_VERSION, '5.3.0', '<')) {
         if (!defined('T_NAMESPACE')) {
             define('T_NAMESPACE', 'namespace');
         }
         if (!defined('T_NS_SEPARATOR')) {
             define('T_NS_SEPARATOR', '\\');
         }
     }
 }
開發者ID:siite,項目名稱:choose-sa-cloud,代碼行數:36,代碼來源:ClassFileLocator.php

示例13: __construct

 /**
  * Initializes an instance of <b>OfTypeIterator</b>.
  *
  * @param Iterator $iterator
  * @param string   $type
  */
 public function __construct(Iterator $iterator, $type)
 {
     parent::__construct($iterator);
     switch (strtolower($type)) {
         case 'int':
         case 'integer':
             $this->acceptCallback = function ($current) {
                 return is_int($current);
             };
             break;
         case 'float':
         case 'double':
             $this->acceptCallback = function ($current) {
                 return is_float($current);
             };
             break;
         case 'string':
             $this->acceptCallback = function ($current) {
                 return is_string($current);
             };
             break;
         case 'bool':
         case 'boolean':
             $this->acceptCallback = function ($current) {
                 return is_bool($current);
             };
             break;
         default:
             $this->acceptCallback = function ($current) use($type) {
                 return $current instanceof $type;
             };
     }
 }
開發者ID:robations,項目名稱:linq,代碼行數:39,代碼來源:OfTypeIterator.php

示例14: foreach

 function __construct(\Iterator $iterator, array $ignored)
 {
     parent::__construct($iterator);
     foreach ($ignored as $folder) {
         $this->ignored[] = $folder;
     }
 }
開發者ID:florinmatthew,項目名稱:find-file-content,代碼行數:7,代碼來源:IgnoredFoldersIterator.php

示例15: __construct

 /**
  * @param \Traversable   $transitions
  * @param object         $subject
  * @param \ArrayAccess   $context
  * @param EventInterface $event
  */
 public function __construct(\Traversable $transitions, $subject, \ArrayAccess $context, EventInterface $event = null)
 {
     parent::__construct(new \IteratorIterator($transitions));
     $this->subject = $subject;
     $this->context = $context;
     $this->event = $event;
 }
開發者ID:klaussilveira,項目名稱:statemachine,代碼行數:13,代碼來源:ActiveTransitionFilter.php


注:本文中的FilterIterator類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。