Completed
Push — master ( c917db...06a7b2 )
by Valentin
03:59
created

EvalMaterializer::materialize()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
namespace Cycle\ORM\Promise\Materizalizer;
4
5
use Cycle\ORM\Promise\Declaration\Declaration;
6
use Cycle\ORM\Promise\MaterializerInterface;
7
8
class EvalMaterializer implements MaterializerInterface
9
{
10
    public function materialize(string $code, Declaration $declaration): void
11
    {
12
        if (class_exists($declaration->class->getNamespacesName())) {
13
            throw new \RuntimeException("Class `{$declaration->class->getNamespacesName()}` already exists.");
14
        }
15
16
        $output = ltrim($code, "<?php");
17
18
        eval($output);
19
    }
20
}