/**
  * Resolve ReferenceInterface argument into value
  *
  * @param ReferenceInterface $reference
  * @return string
  * @throws ReferenceNotImplementsException
  */
 protected function resolveDependency(ReferenceInterface $reference) : string
 {
     if ($reference instanceof ClassReference) {
         $value = $reference->getClassName();
         return "\$this->logic('{$value}')";
     } elseif ($reference instanceof NullReference) {
         return 'null';
     } elseif ($reference instanceof ServiceReference) {
         $value = $reference->getName();
         return "\$this->logic('{$value}')";
     } elseif ($reference instanceof StringReference) {
         $value = $reference->getValue();
         return "'{$value}'";
     } elseif ($reference instanceof FloatReference) {
         $value = $reference->getValue();
         return "{$value}";
     } elseif ($reference instanceof BoolReference) {
         $value = $reference->getValue();
         return "{$value}";
     } elseif ($reference instanceof IntegerReference) {
         $value = $reference->getValue();
         return "{$value}";
     } elseif ($reference instanceof ParameterReference) {
         $value = $reference->getParameterName();
         return "\$this->parameter('{$value}')";
     } elseif ($reference instanceof ConstantReference) {
         $value = $reference->getValue();
         return "{$value}";
     } elseif ($reference instanceof CollectionReference) {
         /** @var array $value */
         $value = $reference->getCollection();
         $string = '[';
         // Iterate items
         foreach ($value as $item) {
             $value = $this->resolveDependency($item->getValue());
             $key = $this->resolveDependency($item->getKey());
             $string .= "{$key} => {$value}, ";
         }
         // Remove comma
         $string = rtrim($string, ', ');
         return $string . ']';
     } else {
         throw new ReferenceNotImplementsException(sprintf('Class "%s" does not have correct implementation in generator', get_class($reference)));
     }
 }
 /**
  * Add dependencies which then will be use for automatic creation the definitions
  *
  * @param DefinitionBuilder $definitionBuilder
  * @param array $dependencyList
  * @param ReferenceInterface $reference
  * @param AbstractPropertyDefinition $definition
  * @return array
  * @throws ImplementerForTypeNotFoundException
  */
 protected function addDependency(DefinitionBuilder $definitionBuilder, array &$dependencyList, ReferenceInterface $reference, AbstractPropertyDefinition $definition)
 {
     // Add class dependency to list
     if ($reference instanceof ClassReference) {
         $className = $reference->getClassName();
         // When there is not simple class then resolve it by type
         if ($this->checkIfType($className)) {
             $reference = $this->resolveTypeImplementer($definitionBuilder, $className);
             //                $reference = new ClassReference($className);
             // Set new implementer dependency instead of type one
             $definition->setDependency($reference);
         }
         $dependencyList[$className] = $reference;
     }
 }