Passed
Push — master ( de3d61...be839c )
by Alec
13:42 queued 13s
created

ALoopAdapter   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 21
rs 10
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A error() 0 8 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace AlecRabbit\Spinner\Core\Contract\Loop\A;
6
7
use AlecRabbit\Spinner\Core\Contract\Loop\Contract\ILoop;
8
use Closure;
9
10
/**
11
 * @codeCoverageIgnore
12
 */
13
abstract class ALoopAdapter implements ILoop
14
{
15
    protected static function error(): bool
16
    {
17
        // will be `null` if error handler set by `set_error_handler()` successfully handled the error
18
        $error = error_get_last(); // [889ad594-ca28-4770-bb38-fd5bd8cb1777]
19
20
        return (bool)(($error['type'] ?? 0)
21
            &
22
            (E_ERROR | E_CORE_ERROR | E_COMPILE_ERROR | E_USER_ERROR | E_RECOVERABLE_ERROR));
23
    }
24
25
    abstract public function onSignal(int $signal, Closure $closure): void;
26
27
    abstract public function stop(): void;
28
29
    abstract public function repeat(float $interval, Closure $closure): mixed;
30
31
    abstract public function run(): void;
32
33
    abstract public function cancel(mixed $timer): void;
34
}
35