Completed
Push — master ( fc6b0c...d75285 )
by Shinji
12s queued 10s
created

NanoSleepLoop::invoke()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of the sj-i/php-profiler 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 PhpProfiler\Lib\Loop\LoopProcess;
15
16
use PhpProfiler\Lib\Loop\LoopProcessInterface;
17
18
final class NanoSleepLoop implements LoopProcessInterface
19
{
20
    private int $sleep_nano_seconds;
21
    private LoopProcessInterface $chain;
22
23
    public function __construct(int $sleep_nano_seconds, LoopProcessInterface $chain)
24
    {
25
        $this->sleep_nano_seconds = $sleep_nano_seconds;
26
        $this->chain = $chain;
27
    }
28
29
    public function invoke(): bool
30
    {
31
        if (!$this->chain->invoke()) {
32
            return false;
33
        }
34
        time_nanosleep(0, $this->sleep_nano_seconds);
35
        return true;
36
    }
37
}
38