Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of PHPUnit.
4
 *
5
 * (c) Sebastian Bergmann <sebastian@phpunit.de>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace PHPUnit\Util\Xml;
11
 
12
use function count;
13
use ArrayIterator;
14
use Countable;
15
use DOMNode;
16
use DOMNodeList;
17
use IteratorAggregate;
18
 
19
/**
20
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
21
 *
22
 * @template-implements IteratorAggregate<int, DOMNode>
23
 */
24
final class SnapshotNodeList implements Countable, IteratorAggregate
25
{
26
    /**
27
     * @var DOMNode[]
28
     */
29
    private $nodes = [];
30
 
31
    public static function fromNodeList(DOMNodeList $list): self
32
    {
33
        $snapshot = new self;
34
 
35
        foreach ($list as $node) {
36
            $snapshot->nodes[] = $node;
37
        }
38
 
39
        return $snapshot;
40
    }
41
 
42
    public function count(): int
43
    {
44
        return count($this->nodes);
45
    }
46
 
47
    public function getIterator(): ArrayIterator
48
    {
49
        return new ArrayIterator($this->nodes);
50
    }
51
}