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\TextUI\XmlConfiguration;
11
 
12
use IteratorAggregate;
13
 
14
/**
15
 * @internal This class is not covered by the backward compatibility promise for PHPUnit
16
 *
17
 * @psalm-immutable
18
 *
19
 * @template-implements IteratorAggregate<int, Group>
20
 */
21
final class GroupCollection implements IteratorAggregate
22
{
23
    /**
24
     * @var Group[]
25
     */
26
    private $groups;
27
 
28
    /**
29
     * @param Group[] $groups
30
     */
31
    public static function fromArray(array $groups): self
32
    {
33
        return new self(...$groups);
34
    }
35
 
36
    private function __construct(Group ...$groups)
37
    {
38
        $this->groups = $groups;
39
    }
40
 
41
    /**
42
     * @return Group[]
43
     */
44
    public function asArray(): array
45
    {
46
        return $this->groups;
47
    }
48
 
49
    /**
50
     * @return string[]
51
     */
52
    public function asArrayOfStrings(): array
53
    {
54
        $result = [];
55
 
56
        foreach ($this->groups as $group) {
57
            $result[] = $group->name();
58
        }
59
 
60
        return $result;
61
    }
62
 
63
    public function isEmpty(): bool
64
    {
65
        return empty($this->groups);
66
    }
67
 
68
    public function getIterator(): GroupCollectionIterator
69
    {
70
        return new GroupCollectionIterator($this);
71
    }
72
}