Failed Conditions
Push — mixed-collections ( 23b545 )
by Michael
03:24
created

Collection::count()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Doctrine\Annotations\Parser\Ast\Collection;
6
7
use Countable;
8
use Doctrine\Annotations\Parser\Ast\ValuableNode;
9
use Doctrine\Annotations\Parser\Ast\Value;
10
use Doctrine\Annotations\Parser\Visitor\Visitor;
11
use IteratorAggregate;
12
use function count;
13
14
final class Collection implements Value, IteratorAggregate, Countable
15
{
16
17
    /** @var ValuableNode[] */
18
    private $items;
19
20
    public function __construct(Entry ...$items)
21
    {
22
        $this->items = $items;
23
    }
24
25
    /**
26
     * @return Collection[]
27
     */
28
    public function getIterator() : iterable
29
    {
30
        yield from $this->items;
0 ignored issues
show
Bug Best Practice introduced by
The expression YieldFromNode returns the type Generator which is incompatible with the documented return type Doctrine\Annotations\Par...Collection\Collection[].
Loading history...
31
    }
32
33
    public function count() : int
34
    {
35
        return count($this->items);
36
    }
37
38
    public function dispatch(Visitor $visitor) : void
39
    {
40
        $visitor->visitCollection($this);
41
    }
42
}
43