ArrayAdapter::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
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