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

ALoopAdapter::error()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 8
rs 10
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