Passed
Push — master ( b2cf4a...c48dc4 )
by Samuel
02:01
created

Hydrator   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 22
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A hydrate() 0 10 2
1
<?php
2
3
namespace App\Core\Infrastructure\Utility;
4
5
final class Hydrator
6
{
7
    /**
8
     * Hydrate a collection of objects with data from an array items.
9
     *
10
     * @template T
11
     *
12
     * @param array<array<string, mixed>> $rows The items
13
     * @param class-string<T> $class The FQN
0 ignored issues
show
Documentation Bug introduced by
The doc comment class-string<T> at position 0 could not be parsed: Unknown type name 'class-string' at position 0 in class-string<T>.
Loading history...
14
     *
15
     * @return T[] The list of object
16
     */
17 2
    public function hydrate(array $rows, string $class): array
18
    {
19 2
        $result = [];
20
21 2
        foreach ($rows as $row) {
22
            // Some classes like UserData have a restriction
23 2
            $result[] = new $class($row, true);
24
        }
25
26 2
        return $result;
27
    }
28
}
29