Passed
Pull Request — master (#22)
by Aleksei
02:39
created

ValueFieldState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 28
ccs 12
cts 12
cp 1
rs 10
c 1
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A clear() 0 5 1
A addParamFromBuffer() 0 4 1
A addParam() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Yiisoft\Http\Header\Parser;
6
7
class ValueFieldState
8
{
9
    public int $part = 0;
10
    public string $buffer = '';
11
    public string $key = '';
12
    public string $value = '';
13
    public array $params = [];
14
15
    public ?ParsingException $error = null;
16
17 51
    public function addParam($key, $value): void
18
    {
19 51
        if (!array_key_exists($key, $this->params)) {
20 51
            $this->params[$key] = $value;
21
        }
22 51
    }
23
24 51
    public function addParamFromBuffer(): void
25
    {
26 51
        $this->addParam($this->key, $this->buffer);
27 51
        $this->key = $this->buffer = '';
28 51
    }
29
30 83
    public function clear(): void
31
    {
32 83
        $this->key = $this->buffer = $this->value = '';
33 83
        $this->params = [];
34 83
        $this->error = null;
35 83
    }
36
}
37