SimpleLoop   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 4
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canContinue() 0 3 1
A __construct() 0 2 1
A getMemoryLimit() 0 3 1
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