SimpleQueryHydrator::hydrate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 9
ccs 6
cts 6
cp 1
rs 9.6666
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
/*
4
 * This file is part of the "RocketORM" package.
5
 *
6
 * https://github.com/RocketORM/ORM
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Rocket\ORM\Model\Query\Hydrator;
13
14
use Rocket\ORM\Model\Object\RocketObject;
15
16
/**
17
 * @author Sylvain Lorinet <[email protected]>
18
 */
19
class SimpleQueryHydrator implements QueryHydratorInterface
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $modelNamespace;
25
26
    /**
27
     * @param string $modelNamespace
28
     */
29 1
    public function __construct($modelNamespace)
30
    {
31 1
        $this->modelNamespace = $modelNamespace;
32 1
    }
33
34
    /**
35
     * @inheritdoc
36
     */
37 1
    public function hydrate(\PDOStatement $stmt)
38
    {
39 1
        $objects = [];
40 1
        while ($row = $stmt->fetch(\PDO::FETCH_ASSOC)) {
41 1
            $objects[] = new RocketObject($row, $this->modelNamespace);
42 1
        }
43
44 1
        return $objects;
45
    }
46
}
47