| Server IP : 213.186.33.4 / Your IP : 216.73.216.193 Web Server : Apache System : Linux webm006.cluster103.gra.hosting.ovh.net 5.15.206-ovh-vps-grsec-zfs-classid #1 SMP Fri May 15 02:41:25 UTC 2026 x86_64 User : awebpaca ( 35430) PHP Version : 8.5.0 Disable Function : _dyuweyrj4,_dyuweyrj4r,dl MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/awebpaca/blog/libraries/vendor/joomla/compat/src/ |
Upload File : |
<?php
/**
* Part of the Joomla Framework Compat Package
*
* @copyright Copyright (C) 2005 - 2014 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE
*/
/**
* CallbackFilterIterator using the callback to determine which items are accepted or rejected.
*
* @link http://php.net/manual/en/class.callbackfilteriterator.php
* @since 1.2.0
*/
class CallbackFilterIterator extends \FilterIterator
{
/**
* The callback to check value.
*
* @var callable
*
* @since 1.2.0
*/
protected $callback = null;
/**
* 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);
}
/**
* This method calls the callback with the current value, current key and the inner iterator.
* The callback is expected to return TRUE if the current item is to be accepted, or FALSE otherwise.
*
* @link http://www.php.net/manual/en/callbackfilteriterator.accept.php
*
* @return boolean True if the current element is acceptable, otherwise false.
*
* @since 1.2.0
*/
public function accept()
{
$inner = $this->getInnerIterator();
return call_user_func_array(
$this->callback,
array(
$inner->current(),
$inner->key(),
$inner
)
);
}
}