Entry::loadVars()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 7
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 10
ccs 8
cts 8
cp 1
crap 2
rs 10
1
<?php
2
3
namespace kalanis\kw_input\Loaders;
4
5
6
use kalanis\kw_input\Entries;
7
8
9
/**
10
 * Class Entry
11
 * @package kalanis\kw_input\Loaders
12
 * Load input arrays into normalized entries
13
 */
14
class Entry extends ALoader
15
{
16
    /**
17
     * Transform input values to something more reliable
18
     * @param string $source
19
     * @param array<string|int, string|int|bool|string[]|int[]> $array
20
     * @return Entries\Entry[]
21
     */
22 4
    public function loadVars(string $source, $array): array
23
    {
24 4
        $result = [];
25 4
        $entries = new Entries\Entry();
26 4
        foreach ($array as $postedKey => $posted) {
27 4
            $entry = clone $entries;
28 4
            $entry->setEntry($source, strval($postedKey), $posted);
29 4
            $result[] = $entry;
30
        }
31 4
        return $result;
32
    }
33
}
34