/**
  * Return prepared method name from property eg. getNameOrSurname
  *
  * @return string
  */
 public function getPreparedName()
 {
     return sprintf("set%s", parent::getPreparedName());
 }
コード例 #2
0
 /**
  * @param MethodManager $method
  * @return string
  * @throws RendererException
  * @throws UnrecognizedItemToRenderException
  */
 protected function renderMethod(MethodManager $method)
 {
     $template = $method->getTemplate();
     $tags = $method->getTemplateTags();
     $property = $method->getProperty();
     $propertyName = $property->getPreparedName();
     $methodName = $method->getPreparedName();
     $comment = sprintf('For property "%s"', $propertyName);
     $args = [];
     switch (true) {
         case $method instanceof MethodGetterManager:
             $args[RenderableInterface::TAG_COMMENT] = $comment;
             $args[RenderableInterface::TAG_PROPERTY_TYPE] = $property->getType();
             $args[RenderableInterface::TAG_METHOD_NAME] = $methodName;
             $args[RenderableInterface::TAG_PROPERTY_NAME] = $propertyName;
             break;
         case $method instanceof MethodGetterInterfaceManager:
             $args[RenderableInterface::TAG_COMMENT] = $comment;
             $args[RenderableInterface::TAG_PROPERTY_TYPE] = $property->getType();
             $args[RenderableInterface::TAG_METHOD_NAME] = $methodName;
             break;
         case $method instanceof MethodGetterBooleanManager:
             $args[RenderableInterface::TAG_COMMENT] = $comment;
             $args[RenderableInterface::TAG_PROPERTY_TYPE] = $property->getType();
             $args[RenderableInterface::TAG_METHOD_NAME] = $methodName;
             $args[RenderableInterface::TAG_PROPERTY_NAME] = $propertyName;
             break;
         case $method instanceof MethodGetterBooleanInterfaceManager:
             $args[RenderableInterface::TAG_COMMENT] = $comment;
             $args[RenderableInterface::TAG_PROPERTY_TYPE] = $property->getType();
             $args[RenderableInterface::TAG_METHOD_NAME] = $methodName;
             break;
         case $method instanceof SetterMethodInterface:
             $typeHintitng = '';
             if ($method->canAddTypeHinting()) {
                 $typeHintitng = sprintf('\\%s ', $property->getTypeName());
             }
             $optionalPart = '';
             if ($property->isOptional()) {
                 $optionalPart = ' = null';
             }
             $args[RenderableInterface::TAG_COMMENT] = $comment;
             $args[RenderableInterface::TAG_PROPERTY_TYPE] = $property->getType();
             $args[RenderableInterface::TAG_TYPE_HINTING] = $typeHintitng;
             $args[RenderableInterface::TAG_METHOD_NAME] = $methodName;
             $args[RenderableInterface::TAG_PROPERTY_NAME] = $propertyName;
             $args[RenderableInterface::TAG_OPTIONAL_PART] = $optionalPart;
             break;
         default:
             throw $this->getExceptionUnrecognizedItem($method);
     }
     return $this->addNewLineAfter($this->addIndentation($this->replace($tags, $args, $template), self::INDENT_4_SPACES));
 }