| Server IP : 217.11.249.137 / Your IP : 216.73.216.54 Web Server : Apache System : FreeBSD triton.blueboard.cz 13.5-STABLE FreeBSD 13.5-STABLE stable/13-a3d32f9e6 GENERIC amd64 User : www ( 80) PHP Version : 8.0.30 Disable Function : ini_restore, show_source, socket_select, socket_create_listen, socket_create_pair, socket_listen, socket_strerror, shell_exec, proc_nice, proc_terminate, readlink, symlink, link, pfsocketopen, ini_alter, dl, pcntl_exec, pcntl_fork, pcntl_signal, pcntl_waitpid, pcntl_wexitstatus, pcntl_wifexited, pcntl_wifsignaled, pcntl_wifsignaled, pcntl_wifstoped, pcntl_wifstopsig, pcntl_wtermsig, socket_accept, socket_bind, socket_create, socket_create_listen, popen, zlib_decode MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /data/www/24781/extramagazin_cz/www/wp-content/plugins/amp/src/Dom/ |
Upload File : |
<?php
/**
* Class ElementList
*
* @package AmpProject\AmpWP
*/
namespace AmpProject\AmpWP\Dom;
use AmpProject\AmpWP\Component\CaptionedSlide;
use IteratorAggregate;
use Countable;
use DOMElement;
use ArrayIterator;
/**
* Class ElementList
*
* @internal
* @since 1.5.0
*/
final class ElementList implements IteratorAggregate, Countable {
/**
* The elements, possibly with captions.
*
* @var array
*/
private $elements = [];
/**
* Adds an element to the list, possibly with a caption.
*
* @param DOMElement $element The element to add, possibly an image.
* @param DOMElement|null $caption The caption for the element.
* @return ElementList A clone of this list, with the new element added.
*/
public function add( DOMElement $element, ?DOMElement $caption = null ): ElementList {
$cloned_list = clone $this;
$cloned_list->elements[] = null === $caption ? $element : new CaptionedSlide( $element, $caption );
return $cloned_list;
}
/**
* Gets an iterator with the elements.
*
* This together with the IteratorAggregate turns the object into a "Traversable",
* so you can just foreach over it and receive its elements in the correct type.
*
* @return ArrayIterator An iterator with the elements.
*/
public function getIterator(): ArrayIterator {
return new ArrayIterator( $this->elements );
}
/**
* Gets the count of the elements.
*
* @return int The number of elements.
*/
public function count(): int {
return count( $this->elements );
}
}