-
Notifications
You must be signed in to change notification settings - Fork 1
/
All.php
38 lines (31 loc) · 737 Bytes
/
All.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
declare(strict_types=1);
namespace TijmenWierenga\Guzzle\Mocking\Conditions;
use Closure;
use Psr\Http\Message\RequestInterface;
/**
* @psalm-immutable
*/
final class All
{
/**
* @var Closure[]
*/
private array $conditions;
public function __construct(callable ...$conditions)
{
$this->conditions = array_map(
fn (callable $condition): Closure => Closure::fromCallable($condition),
$conditions
);
}
public function __invoke(RequestInterface $request): bool
{
foreach ($this->conditions as $condition) {
if ($condition($request) === false) {
return false;
}
}
return true;
}
}