/**
  * Add the constructor method for the operation
  */
 private function addConstructorMethod()
 {
     $requiredParameters = $this->operationDefinition->getRequiredParams();
     $methodGenerator = new MethodGenerator('__construct');
     $defaultParams = $this->operationDefinition->getDefaultParams();
     $body = '';
     if (count($defaultParams)) {
         $body = '$defaultParams = [' . PHP_EOL;
         foreach ($defaultParams as $param) {
             $body .= sprintf("    '%s' => '%s',", $param->getName(), $param->getDefault());
             $body .= PHP_EOL;
         }
         $body .= '];' . PHP_EOL;
         $body .= '$this->setParams($defaultParams);' . PHP_EOL;
     }
     $constructorParams = [];
     $constructorParams[] = new ParameterGenerator('api', $this->apiGenerator->getFQCN());
     $body .= '$this->api = $api;' . PHP_EOL;
     foreach ($requiredParameters as $param) {
         $normalizedParamName = normalizeParamName($param->getName());
         $constructorParams[] = new ParameterGenerator($normalizedParamName, $param->getType());
         $body .= sprintf("\$this->parameters['%s'] = \$%s;" . PHP_EOL, $param->getName(), $normalizedParamName);
     }
     $methodGenerator->setParameters($constructorParams);
     $methodGenerator->setBody($body);
     $this->classGenerator->addMethodFromGenerator($methodGenerator);
 }
 /**
  * Add the methods that return the operations in the API.
  */
 function addOperationGetter($methodName, OperationDefinition $operation, OperationGenerator $operationGenerator)
 {
     $operationName = $this->normalizeMethodName($methodName);
     $operationClassName = $this->normalizeClassName($methodName);
     $methodGenerator = new MethodGenerator($operationName);
     $apiParameters = $this->getAPIParameters();
     $body = '';
     //All required parameters must be passed in when the operation is created.
     $requiredParameters = $operation->getRequiredParams();
     $paramsStrings = [];
     $requiredParamsStringsWithDollar = [];
     $tags = [];
     $requiredParamsStringsWithDollar[] = '$this';
     foreach ($requiredParameters as $requiredParam) {
         $translatedParam = ucfirst($this->translateParameter($requiredParam->getName()));
         $normalizedParamName = normalizeParamName($requiredParam->getName());
         if (array_key_exists($requiredParam->getName(), $apiParameters) == true) {
             $requiredParamsStringsWithDollar[] = sprintf('$this->get%s()', $translatedParam);
         } else {
             $paramsStrings[] = $normalizedParamName;
             $tags[] = new GenericTag('param', $requiredParam->getType() . ' $' . $requiredParam->getName() . ' ' . $requiredParam->getDescription());
             //TODO - replace with array_map on $paramsStrings
             $requiredParamsStringsWithDollar[] = '$' . $normalizedParamName;
         }
     }
     $paramString = implode(', ', $requiredParamsStringsWithDollar);
     $methodGenerator->setParameters($paramsStrings);
     $tags[] = new GenericTag('return', '\\' . $operationGenerator->getFQCN() . ' The new operation ');
     $body .= "\$instance = new {$operationClassName}({$paramString});" . PHP_EOL;
     $body .= "return \$instance;" . PHP_EOL;
     $docBlockGenerator = new DocBlockGenerator($methodName);
     $docBlockGenerator->setLongDescription($operation->getSummary());
     $docBlockGenerator->setTags($tags);
     $methodGenerator->setDocBlock($docBlockGenerator);
     $methodGenerator->setBody($body);
     $this->classGenerator->addMethodFromGenerator($methodGenerator);
     $this->interfaceGenerator->addMethodFromGenerator($methodGenerator);
 }