/**
  * {@inheritDoc}
  */
 public function generate($name)
 {
     if (!$this->isAbleToGenerate($name)) {
         throw new UnableToGenerateTypeOutlineException('Class type "' . $name . '" does not exist');
     }
     if (isset($this->loadedClasses[$name])) {
         return $this->loadedClasses[$name];
     }
     $classMeta = $this->classesConfig[$name];
     $parentClass = null;
     if (isset($classMeta['extend'])) {
         $parentClass = $this->schemaOutline->getTypeOutline($classMeta['extend']);
         if (!$parentClass instanceof ClassOutline) {
             $msg = 'Parent class "' . $classMeta['extend'] . '" must be a class outline instance';
             throw new UnableToGenerateTypeOutlineException($msg);
         }
     }
     $classOutline = new ClassOutline($name, array(), $parentClass);
     $this->loadedClasses[$name] = $classOutline;
     if (isset($classMeta['properties'])) {
         foreach ($classMeta['properties'] as $propertyName => $property) {
             $propertyOutline = new PropertyOutline($propertyName, $this->schemaOutline->getTypeOutline($property['type']));
             if (isset($property['default'])) {
                 $propertyOutline->setDefaultValue($property['default']);
             }
             if (isset($property['nullable'])) {
                 $propertyOutline->setIsNullable($property['nullable']);
             }
             $classOutline->addProperty($propertyOutline);
         }
     }
     unset($this->loadedClasses[$name]);
     return $classOutline;
 }
 /**
  * {@inheritDoc}
  */
 public function generate($name)
 {
     $typeName = $this->extractTypeName($name);
     if (!$typeName) {
         throw new UnableToGenerateTypeOutlineException('Invalid name to generate collection outline');
     }
     $type = $this->schemaOutline->getTypeOutline($typeName);
     $name = 'collection<' . $type->getName() . '>';
     return new CollectionOutline($name, $type);
 }
 /**
  * {@inheritDoc}
  */
 public function generate($name)
 {
     $typeNames = $this->extractTypeNames($name);
     if (count($typeNames) < 2) {
         $msg = 'Choice type "' . $name . '" defines only one type. At least 2 required';
         throw new UnableToGenerateTypeOutlineException($msg);
     }
     $name = implode('|', $typeNames);
     $outline = new ChoiceTypeOutline($name);
     foreach ($typeNames as $typeName) {
         $outline->addTypeOutline($this->schemaOutline->getTypeOutline($typeName));
     }
     return $outline;
 }
 /**
  * {@inheritDoc}
  */
 public function generate($name)
 {
     if (!$this->isAbleToGenerate($name)) {
         throw new UnableToGenerateTypeOutlineException('Invalid name "' . $name . '" to generate map outline');
     }
     $types = $this->extractTypes($name);
     if ($types === false) {
         throw new UnableToGenerateTypeOutlineException('Invalid name "' . $name . '" to generate map outline');
     }
     list($keyTypeName, $valueTypeName) = $types;
     $keyTypeOutline = $this->schemaOutline->getTypeOutline($keyTypeName);
     $valueTypeOutline = $this->schemaOutline->getTypeOutline($valueTypeName);
     $name = vsprintf('map<%s,%s>', array($keyTypeOutline->getName(), $valueTypeOutline->getName()));
     return new MapOutline($name, $keyTypeOutline, $valueTypeOutline);
 }