1
<?php
2

3
declare(strict_types=1);
4

5
namespace Kreait\Firebase\Http;
6

7
use IteratorAggregate;
8
use Psr\Http\Message\RequestInterface;
9
use Traversable;
10

11
/**
12
 * @implements IteratorAggregate<RequestInterface>
13
 */
14
final class Requests implements IteratorAggregate
15
{
16
    /** @var RequestInterface[] */
17
    private $requests;
18

19 3
    public function __construct(RequestInterface ...$requests)
20
    {
21 3
        $this->requests = $requests;
22
    }
23

24 3
    public function findBy(callable $callable): ?RequestInterface
25
    {
26 3
        $results = \array_filter($this->requests, $callable);
27

28 3
        return \array_shift($results) ?: null;
29
    }
30

31
    /**
32
     * @codeCoverageIgnore
33
     *
34
     * @return Traversable<RequestInterface>|RequestInterface[]
35
     */
36
    public function getIterator()
37
    {
38
        yield from $this->requests;
39
    }
40
}

Read our documentation on viewing source code .

Loading