SoftLimitTrait   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 57.14%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 17
ccs 4
cts 7
cp 0.5714
rs 10
c 0
b 0
f 0
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A memoryLimitReached() 0 13 3
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Queue\Cli;
6
7
trait SoftLimitTrait
8
{
9
    abstract protected function getMemoryLimit(): int;
10
11 5
    protected function memoryLimitReached(): bool
12
    {
13 5
        $limit = $this->getMemoryLimit();
14
15 5
        if ($limit !== 0) {
16
            $usage = memory_get_usage(true);
17
18
            if ($usage >= $limit) {
19
                return true;
20
            }
21
        }
22
23 5
        return false;
24
    }
25
}
26