Passed
Pull Request — master (#22)
by Aleksei
07:47
created

ValueFieldState   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

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