Conditions | 6 |
Paths | 10 |
Total Lines | 23 |
Code Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 9 |
CRAP Score | 6.0359 |
Changes | 0 |
1 | <?php |
||
15 | 3 | public function build($class) |
|
16 | { |
||
17 | 3 | if (is_object($class)) { |
|
18 | $class = get_class($class); |
||
19 | } |
||
20 | 3 | if (!class_exists($class)) { |
|
21 | 3 | throw new \InvalidArgumentException(sprintf("Class %s does not exist", $class)); |
|
22 | 3 | } |
|
23 | 3 | $context = new HydratorContext; |
|
24 | 3 | $context->setClass($class); |
|
25 | 3 | $reflection = new \ReflectionClass($class); |
|
26 | $annotationReader = new AnnotationReader(); |
||
27 | 3 | foreach ($reflection->getProperties() as $property) { |
|
28 | $annotations = $annotationReader->getPropertyAnnotations($property); |
||
29 | $metadata = new PropertyMetadata($property->getName()); |
||
30 | foreach($annotations as $annotation) { |
||
31 | if ($annotation instanceof PopulatorAnnotation) { |
||
32 | $annotation->process($metadata, $this); |
||
33 | } |
||
34 | } |
||
35 | $context->addProperty($metadata); |
||
36 | } |
||
37 | return $context; |
||
38 | } |
||
40 |