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 //$param->getName()
            );
        }
        
        
        
        $methodGenerator->setParameters($constructorParams);
        $methodGenerator->setBody($body);
        $this->classGenerator->addMethodFromGenerator($methodGenerator);
    }
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 //$param->getName()
            );
        }
        
        
        
        $methodGenerator->setParameters($constructorParams);
        $methodGenerator->setBody($body);
        $this->classGenerator->addMethodFromGenerator($methodGenerator);
    }
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 //$param->getName() ) ; } $ methodGenerator -> setParameters ( $ constructorParams ) ; $ methodGenerator -> setBody ( $ body ) ; $ this -> classGenerator -> addMethodFromGenerator ( $ methodGenerator ) ; }
Add the constructor method for the operation
Add the constructor method for the operation