| Conditions | 6 | 
| Paths | 6 | 
| Total Lines | 26 | 
| Code Lines | 20 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Tests | 19 | 
| CRAP Score | 6 | 
| Changes | 1 | ||
| Bugs | 0 | Features | 0 | 
| 1 | <?php | ||
| 27 | 14 | public function build(string $className): AutowireItemInterface | |
| 28 |     { | ||
| 29 | 14 |         if ($this->itemProvider->hasItem($className)) { | |
| 30 | 6 | return $this->itemProvider->getItem($className); | |
| 31 | } | ||
| 32 | 14 |         if (class_exists($className)) { | |
| 33 | 13 |             if (isset($this->buildClasses[$className])) { | |
| 34 | 1 |                 throw new ContainerException("$className has circular reference dependency."); | |
| 35 | } | ||
| 36 | 13 | $this->buildClasses[$className] = true; | |
| 37 | 13 | $reflection = new \ReflectionClass($className); | |
| 38 | 13 |             if (!$reflection->isInstantiable()) { | |
| 39 | 1 |                 throw new ContainerException("$className is not instantiable."); | |
| 40 | } | ||
| 41 | 12 | $constructor = $reflection->getConstructor(); | |
| 42 | 12 |             if (null !== $constructor) { | |
| 43 | 12 | $args = (new DependencyBuilder($this->itemProvider, $this)) | |
| 44 | 12 | ->buildParameters($constructor->getParameters()); | |
| 45 |             } else { | ||
| 46 | 2 | $args = []; | |
| 47 | } | ||
| 48 | 11 | $classItem = new ClassItem($className, $args); | |
| 49 | 11 | $this->itemProvider->addItem($className, $classItem); | |
| 50 | 11 | return $classItem; | |
| 51 |         } else { | ||
| 52 | 1 | throw new NotFoundException($className); | |
| 53 | } | ||
| 56 |