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

ValueFieldState::clear()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 3
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 5
ccs 4
cts 4
cp 1
crap 1
rs 10
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