OnlyOnceCondition   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
dl 0
loc 11
rs 10
c 1
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A shouldContinue() 0 7 2
1
<?php
2
3
/**
4
 * This file is part of the reliforp/reli-prof package.
5
 *
6
 * (c) sji <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Reli\Lib\Loop\LoopCondition;
15
16
final class OnlyOnceCondition implements LoopConditionInterface
17
{
18
    private bool $has_run = false;
19
20
    public function shouldContinue(): bool
21
    {
22
        if ($this->has_run) {
23
            return false;
24
        }
25
        $this->has_run = true;
26
        return true;
27
    }
28
}
29