RocketObject::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
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\Object;
13
14
use Rocket\ORM\Model\ModelInterface;
15
16
/**
17
 * @author Sylvain Lorinet <[email protected]>
18
 */
19
class RocketObject extends \ArrayObject
20
{
21
    /**
22
     * @var string
23
     */
24
    protected $modelNamespace;
25
26
    /**
27
     * @param array  $values
28
     * @param string $modelNamespace
29
     */
30 1
    public function __construct($values, $modelNamespace)
31
    {
32 1
        $this->modelNamespace = $modelNamespace;
33
34 1
        parent::__construct($values, \ArrayObject::STD_PROP_LIST);
35 1
    }
36
37
    /**
38
     * @return ModelInterface
39
     */
40 1
    public function hydrate()
41
    {
42
        /** @var ModelInterface $model */
43 1
        $model = new $this->modelNamespace;
44 1
        $model->hydrate($this->getArrayCopy());
45
46 1
        return $model;
47
    }
48
}
49