Flags::set()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 2.032
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Sql\Component;
5
6
class Flags extends Component
7
{
8
    protected $list = [];
9
10 2
    public function set(string $flag, bool $enable = true): void
11
    {
12 2
        if ($enable) {
13 2
            $this->list[$flag] = true;
14
        } else {
15
            unset($this->list[$flag]);
16
        }
17 2
    }
18
19 2
    public function get(): array
20
    {
21 2
        return array_keys($this->list);
22
    }
23
24 19
    public function build(): string
25
    {
26 19
        if (empty($this->list)) {
27 17
            return '';
28
        }
29
30 2
        return ' ' . implode(' ', $this->get());
31
    }
32
}
33