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

EvalMaterializer   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 2
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A materialize() 0 10 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
}