generatePropertyMethod() public static method

public static generatePropertyMethod ( $prefix, $property ) : string
$prefix
$property
return string
Ejemplo n.º 1
0
 /**
  * @param ContextInterface|PropertyContext $context
  *
  * @throws AssemblerException
  */
 public function assemble(ContextInterface $context)
 {
     $class = $context->getClass();
     $property = $context->getProperty();
     try {
         $methodName = Normalizer::generatePropertyMethod('get', $property->getName());
         $class->removeMethod($methodName);
         $class->addMethodFromGenerator(MethodGenerator::fromArray(['name' => $methodName, 'parameters' => [], 'visibility' => MethodGenerator::VISIBILITY_PUBLIC, 'body' => sprintf('return $this->%s;', $property->getName()), 'docblock' => DocBlockGenerator::fromArray(['tags' => [['name' => 'return', 'description' => $property->getType()]]])]));
     } catch (\Exception $e) {
         throw AssemblerException::fromException($e);
     }
 }
Ejemplo n.º 2
0
 /**
  * @return string
  */
 public function setterName()
 {
     return Normalizer::generatePropertyMethod('set', $this->getName());
 }