/** * Add a method to asynchronousl execute and parse the response of a previously created request. */ function addDispatchAsyncMethod() { $methodGenerator = new MethodGenerator('dispatchAsync'); $body = 'return $this->api->executeAsync($request, $this, $callable);'; $docBlock = $this->generateExecuteDocBlock('Dispatch the request for this operation and process the response asynchronously. Allows you to modify the request before it is sent.'); $requestParameter = new ParameterGenerator('request', 'Amp\\Artax\\Request'); $methodGenerator->setParameter($requestParameter); $tag = createParamTag($requestParameter, 'The request to be processed'); $docBlock->setTag($tag); $callableParameter = new ParameterGenerator('callable', 'callable'); $methodGenerator->setParameter($callableParameter); $callableTag = createParamTag($callableParameter, 'The callable that processes the response'); $docBlock->setTag($callableTag); $methodGenerator->setDocBlock($docBlock); $methodGenerator->setBody($body); $this->classGenerator->addMethodFromGenerator($methodGenerator); }
/** * */ function addAPIParameterAccessMethod() { foreach ($this->apiParameters as $apiParameter => $type) { $translatedParam = ucfirst($this->translateParameter($apiParameter)); $methodGenerator = new MethodGenerator('get' . $translatedParam); $body = 'return $this->' . $apiParameter . ';' . PHP_EOL; $methodGenerator->setBody($body); $methodGenerator->setDocBlock("@return {$type}"); $this->classGenerator->addMethodFromGenerator($methodGenerator); $methodGenerator = new MethodGenerator('set' . $translatedParam); $body = '$this->' . $apiParameter . ' = $value;' . PHP_EOL; $parameterParameter = new ParameterGenerator('value'); $methodGenerator->setParameter($parameterParameter); $methodGenerator->setBody($body); $this->classGenerator->addMethodFromGenerator($methodGenerator); } }