SimpleLoop::canContinue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Cli;
6
7
class SimpleLoop implements LoopInterface
8
{
9
    use SoftLimitTrait;
10
11
    /**
12
     * @param int $memorySoftLimit Soft RAM limit in bytes. The loop won't let you continue to execute the program if
13
     *     soft limit is reached. Zero means no limit.
14
     */
15 14
    public function __construct(protected int $memorySoftLimit = 0)
16
    {
17 14
    }
18
19 4
    public function canContinue(): bool
20
    {
21 4
        return !$this->memoryLimitReached();
22
    }
23
24 4
    protected function getMemoryLimit(): int
25
    {
26 4
        return $this->memorySoftLimit;
27
    }
28
}
29