-
-
Notifications
You must be signed in to change notification settings - Fork 829
/
Composite.php
38 lines (32 loc) · 903 Bytes
/
Composite.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
/*
* This file is part of Flarum.
*
* For detailed copyright and license information, please view the
* LICENSE file that was distributed with this source code.
*/
namespace Flarum\Install\Prerequisite;
use Illuminate\Support\Collection;
class Composite implements PrerequisiteInterface
{
/**
* @var PrerequisiteInterface[]
*/
protected array $prerequisites = [];
public function __construct(PrerequisiteInterface $first)
{
foreach (func_get_args() as $prerequisite) {
$this->prerequisites[] = $prerequisite;
}
}
public function problems(): Collection
{
return array_reduce(
$this->prerequisites,
function (Collection $errors, PrerequisiteInterface $condition) {
return $errors->concat($condition->problems());
},
new Collection
);
}
}