Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • CachingIterator
  • Filter
  • InstanceFilter
  • Mapper
  • RecursiveFilter
  • Recursor
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Iterators;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Instance iterator filter.
15:  *
16:  * @author     David Grudl
17:  */
18: class InstanceFilter extends \FilterIterator implements \Countable
19: {
20:     /** @var string */
21:     private $type;
22: 
23: 
24:     /**
25:      * Constructs a filter around another iterator.
26:      * @param  \Iterator
27:      * @param  string  class/interface name
28:      */
29:     public function __construct(\Iterator $iterator, $type)
30:     {
31:         $this->type = $type;
32:         parent::__construct($iterator);
33:     }
34: 
35: 
36:     /**
37:      * Expose the current element of the inner iterator?
38:      * @return bool
39:      */
40:     public function accept()
41:     {
42:         return $this->current() instanceof $this->type;
43:     }
44: 
45: 
46:     /**
47:      * Returns the count of elements.
48:      * @return int
49:      */
50:     public function count()
51:     {
52:         return iterator_count($this);
53:     }
54: 
55: }
56: 
Nette 2.0 API documentation generated by ApiGen 2.8.0