/** * @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); } }
/** * @return string */ public function setterName() { return Normalizer::generatePropertyMethod('set', $this->getName()); }