• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP FilterIterator类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中FilterIterator的典型用法代码示例。如果您正苦于以下问题:PHP FilterIterator类的具体用法?PHP FilterIterator怎么用?PHP FilterIterator使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了FilterIterator类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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

 /**
  * Creates a filtered iterator using the callback to determine
  * which items are accepted or rejected.
  *
  * @param   \Iterator  $iterator  The iterator to be filtered.
  * @param   callable   $callback  The callback, which should return TRUE to accept the current item
  *                                or FALSE otherwise. May be any valid callable value.
  *                                The callback should accept up to three arguments: the current item,
  *                                the current key and the iterator, respectively.
  *                                ``` php
  *                                function my_callback($current, $key, $iterator)
  *                                ```
  *
  * @throws  InvalidArgumentException
  *
  * @since   1.2.0
  */
 public function __construct(\Iterator $iterator, $callback)
 {
     if (!is_callable($callback)) {
         throw new \InvalidArgumentException("Argument 2 of CallbackFilterIterator should be callable.");
     }
     $this->callback = $callback;
     parent::__construct($iterator);
 }
开发者ID:deenison,项目名称:joomla-cms,代码行数:25,代码来源:CallbackFilterIterator.php


示例4: __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


示例5: __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


示例6: accept

 /**
  * {@inheritdoc}
  */
 public function accept()
 {
     if (null === $this->status) {
         return true;
     }
     return $this->status == parent::current()->getStatus();
 }
开发者ID:amirkheirabadi,项目名称:pagekit,代码行数:10,代码来源:StatusFilter.php


示例7: __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


示例8: __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


示例9: __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


示例10: 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


示例11: __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


示例12:

 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


示例13: __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


示例14: __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


示例15: 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


示例16: __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


示例17: accept

 public function accept()
 {
     $return = true;
     if ($this->_filter['filterField'] && $this->_filter['filterCompare']) {
         $filterValue = $this->_filter['filterValue'];
         switch ($this->_filter['filterField']) {
             case 'price':
                 $value = parent::current()->getPrice();
                 break;
             case 'code':
                 $value = parent::current()->getCode();
                 break;
             case 'name':
                 $value = parent::current()->getName();
                 break;
             default:
                 $value = false;
                 break;
         }
         switch ($this->_filter['filterCompare']) {
             case 'ilike':
                 $return = $value == $filterValue;
                 break;
             case 'bigger':
                 $return = $value > $filterValue;
                 break;
             case 'smaller':
                 $return = $value < $filterValue;
                 break;
         }
     }
     return $return;
 }
开发者ID:dneprix,项目名称:esky,代码行数:33,代码来源:FilterField.php


示例18: __construct

 /**
  * RegexDirectoryIterator constructor.
  *
  * @param string $path
  *   The path to scan.
  * @param string $regex
  *   The regular expression to match, including delimiters. For example,
  *   /\.yml$/ would list only files ending in .yml.
  */
 public function __construct($path, $regex)
 {
     // Use FilesystemIterator to not iterate over the the . and .. directories.
     $iterator = new \FilesystemIterator($path);
     parent::__construct($iterator);
     $this->regex = $regex;
 }
开发者ID:sojo,项目名称:d8_friendsofsilence,代码行数:16,代码来源:RegexDirectoryIterator.php


示例19: __construct

 /**
  * Constructor
  *
  * @param   \Iterator $iterator     Inner Iterator
  * @param   int       $appearsAfter The unix timestamp of file modification time
  *                                  after which the update should appear in the result list
  */
 public function __construct(\Iterator $iterator, $appearsAfter)
 {
     parent::__construct($iterator);
     $this->appearsAfter = $appearsAfter;
     if (empty($this->appearsAfter) || !is_numeric($appearsAfter)) {
         throw new \InvalidArgumentException(sprintf('Second parameter is expected to be valid number, "%s" given for class "%s".', $appearsAfter, get_class($this)));
     }
 }
开发者ID:recipe,项目名称:scalr,代码行数:15,代码来源:UpdateIncompleteIterator.php


示例20:

 /**
  * 
  * @param \Iterator $iterator
  * @param type $included
  * @param type $excluded
  */
 function __construct(\Iterator $iterator, $included, $excluded = "")
 {
     $this->textIncluded = $included;
     if (NULL !== $excluded) {
         $this->textExcluded = $excluded;
     }
     parent::__construct($iterator);
 }
开发者ID:florinmatthew,项目名称:find-file-content,代码行数:14,代码来源:FileContentFilterIterator.php



注:本文中的FilterIterator类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Filters类代码示例发布时间:2022-05-23
下一篇:
PHP Filter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap