/**
  * @param PropertyOutline $property
  * @param ClassTypeImplementation $classOptions
  * @param ImplementationInterface $implementation
  *
  * @return PropertyDefinition
  */
 protected function createPropertyDefinition(PropertyOutline $property, ClassTypeImplementation $classOptions, ImplementationInterface $implementation)
 {
     $propertyType = $this->schemaLinker->generateType($property->getType(), $implementation);
     $propertyDefinition = new PropertyDefinition($property->getName(), $propertyType);
     $propertyImplementation = $classOptions->getImplementationForProperty($property->getName());
     $targetPropertyName = $propertyImplementation->getTargetPropertyName();
     if ($targetPropertyName) {
         $propertyDefinition->setTargetPropertyName($targetPropertyName);
     }
     // nullable
     $propertyDefinition->setIsNullable($property->isNullable());
     // default value
     if ($property->hasDefaultValue()) {
         $propertyDefinition->setDefaultValue($property->getDefaultValue());
     }
     // setters and getters
     $setter = $propertyImplementation->getSetter();
     if ($setter) {
         $propertyDefinition->setSetterName($setter);
     }
     $getter = $propertyImplementation->getGetter();
     if ($getter) {
         $propertyDefinition->setGetterName($getter);
     }
     return $propertyDefinition;
 }
 /**
  * {@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;
 }
 public function testCannotSetDefaultValueWhenIsNullable()
 {
     $msg = 'Cannot set default value of property since it\'s nullable';
     $this->setExpectedException('\\BadMethodCallException', $msg);
     $this->object->setIsNullable(true)->setDefaultValue('some value');
 }