ArrayAdapter   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A loadEntries() 0 8 2
A getSource() 0 3 1
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