Flag   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 0
dl 0
loc 33
ccs 0
cts 11
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getBit() 0 4 1
A __toString() 0 9 3
1
<?php
2
declare(strict_types=1);
3
namespace Hyphper\Frame;
4
5
class Flag
6
{
7
    const END_STREAM = 0x01;
8
    const ACK = 0x01;
9
    const END_HEADERS = 0x04;
10
    const PADDED = 0x08;
11
    const PRIORITY = 0x20;
12
13
    protected $bit;
14
15
    public function __construct($bit)
16
    {
17
        $this->bit = $bit;
18
    }
19
20
    /**
21
     * @return int (as hex)
22
     */
23
    public function getBit()
24
    {
25
        return $this->bit;
26
    }
27
28
    public function __toString(): string
29
    {
30
        $class = new \ReflectionClass($this);
31
        foreach ($class->getConstants() as $name => $value) {
32
            if ($value == $this->bit) {
33
                return $name;
34
            }
35
        }
36
    }
37
}
38