Test Setup Failed
Push — master ( c4a7db...8049ea )
by Théo
02:17
created

UserGlobalFunctionCollection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the humbug/php-scoper package.
7
 *
8
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
9
 *                    Pádraic Brady <[email protected]>
10
 *
11
 * For the full copyright and license information, please view the LICENSE
12
 * file that was distributed with this source code.
13
 */
14
15
namespace Humbug\PhpScoper\PhpParser\NodeVisitor\Collection;
16
17
use ArrayIterator;
18
use Countable;
19
use IteratorAggregate;
20
use PhpParser\Node\Name\FullyQualified;
21
use function count;
22
23
final class UserGlobalFunctionCollection implements IteratorAggregate, Countable
24
{
25
    /**
26
     * @var FullyQualified[][]
27
     */
28
    private $nodes = [];
29
30
    public function add(FullyQualified $original, FullyQualified $alias): void
31
    {
32
        $this->nodes[] = [$original, $alias];
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function count(): int
39
    {
40
        return count($this->nodes);
41
    }
42
43
    /**
44
     * @inheritdoc
45
     */
46
    public function getIterator(): iterable
47
    {
48
        return new ArrayIterator($this->nodes);
49
    }
50
}
51