ArrayAdapter::loadEntries()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
nc 2
nop 1
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace kalanis\kw_forms\Adapters;
4
5
6
use kalanis\kw_input\Interfaces\IEntry;
7
8
9
/**
10
 * Class ArrayAdapter
11
 * @package kalanis\kw_forms\Adapters
12
 */
13
class ArrayAdapter extends AAdapter
14
{
15
    /** @var array<int|string, string|int|float|null> */
16
    protected array $inputs = [];
17
    protected string $inputType = IEntry::SOURCE_GET;
18
19
    /**
20
     * @param array<int|string, string|int|float|null> $inputs
21
     */
22 1
    public function __construct(array $inputs)
23
    {
24 1
        $this->inputs = $inputs;
25 1
    }
26
27 2
    public function loadEntries(string $inputType): void
28
    {
29 2
        $result = [];
30 2
        foreach ($this->inputs as $postedKey => &$posted) {
31 2
            $result[$this->removeNullBytes(strval($postedKey))] = $this->removeNullBytes(strval($posted));
32
        }
33 2
        $this->vars = $result;
34 2
        $this->inputType = $inputType;
35 2
    }
36
37 2
    public function getSource(): string
38
    {
39 2
        return $this->inputType;
40
    }
41
}
42