AsyncLoop   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 15
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A invoke() 0 8 3
1
<?php
2
3
/**
4
 * This file is part of the reliforp/reli-prof package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Reli\Lib\Loop;
15
16
final class AsyncLoop
17
{
18
    public function __construct(
19
        private AsyncLoopMiddlewareInterface $process
20
    ) {
21
    }
22
23
    public function invoke(): \Generator
24
    {
25
        while (1) {
26
            $result = $this->process->invoke();
27
            if (!$result->valid()) {
28
                break;
29
            }
30
            yield from $result;
31
        }
32
    }
33
}
34