Issues (224)

src/RequirementChecker/Requirements.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the box project.
7
 *
8
 * (c) Kevin Herrera <[email protected]>
9
 *     Théo Fidry <[email protected]>
10
 *
11
 * This source file is subject to the MIT license that is bundled
12
 * with this source code in the file LICENSE.
13
 */
14
15
namespace KevinGH\Box\RequirementChecker;
16
17
use ArrayIterator;
18
use Countable;
19
use IteratorAggregate;
20
use Traversable;
21
use function array_map;
22
use function array_values;
23
use function count;
24
25
final readonly class Requirements implements Countable, IteratorAggregate
0 ignored issues
show
A parse error occurred: Syntax error, unexpected T_READONLY, expecting T_CLASS on line 25 at column 6
Loading history...
26
{
27
    /**
28
     * @param Requirement[] $requirements
29
     */
30
    public function __construct(private array $requirements)
31
    {
32
    }
33
34
    public function getIterator(): Traversable
35
    {
36
        return new ArrayIterator($this->requirements);
37
    }
38
39
    public function count(): int
40
    {
41
        return count($this->requirements);
42
    }
43
44
    public function toArray(): array
45
    {
46
        return array_values(
47
            array_map(
48
                static fn (Requirement $requirement) => $requirement->toArray(),
49
                $this->requirements,
50
            ),
51
        );
52
    }
53
}
54