/**
  * {@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;
 }
 /**
  * @dataProvider isSubclassOfProvider
  */
 public function testIsSubclassOf(ClassOutline $classOutline, $result)
 {
     $this->assertSame($result, $classOutline->isSubclassOf('User'));
 }
 public function testProperHandlingOfCircularReferences()
 {
     $user = new ClassOutline('User');
     $admin = new ClassOutline('Admin');
     $user->addProperty(new PropertyOutline('admin', $admin));
     $admin->addProperty(new PropertyOutline('user', $user));
     $this->classMap->registerClass('User', 'User')->registerClass('Admin', 'Admin');
     $userType = $this->object->generate($user, $this->implementation);
     $properties = $userType->getProperties();
     $adminType = $properties['admin']->getType();
     $properties = $adminType->getProperties();
     $this->assertSame($userType, $properties['user']->getType());
 }