function generateParamFilterBlock(\ArtaxServiceBuilder\Parameter $parameter) {

        $i1 = '    ';//Indent 1
        $i2 = '        ';//Indent 1

        $text = '';

        $text .= sprintf(
            $i1."case ('%s'): {".PHP_EOL,
            $parameter->getName()
        );
        
        foreach ($parameter->getFilters() as $filter) {

            if (is_array($filter)) {
                $text .= $i2.'$args = [];'.PHP_EOL;

                if (isset($filter['args']) == true) {
                    if (is_array($filter['args']) == false) {
                        throw new \ArtaxServiceBuilder\APIBuilderException("Filter args should be an array instead received ".var_export($filter['args'],
                                true
                            )
                        );
                    }

                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as $data) {
                        if ($data == '@value') {
                            $text .= $i2.'$args[] = $value;'.PHP_EOL;
                        }
                        elseif ($data == '@api') {
                            $text .= $i2."\$args[] = \$this->\$api;".PHP_EOL;
                        }
                        else {
                            //It should be a string
                            $text .= $i2."\$args[] = $data;".PHP_EOL;
                        }
                    }
                }

//                $text .= sprintf(
//                    //TODO - we can do better than call_user_func_array
//                    $i2.'$value = call_user_func_array(\'%s\', $args);'.PHP_EOL,
//                    $filter['method']
//                );

                //hard-code for now 2016-02-28
                $text .= sprintf(
                    $i2.'$value = call_user_func_array([$value, \'%s\'], $args);'.PHP_EOL,
                    $filter['method']
                );

            }
            else {
                //TODO - get rid of call_user_func
                $text .= sprintf(
                    $i2.'call_user_func(\'%s\', $value);'.PHP_EOL,
                    $filter
                );
            }
        }

        $text .= $i1.'    break;'.PHP_EOL;
        $text .= $i1.'}'.PHP_EOL;

        return $text;
    }
function generateParamFilterBlock(\ArtaxServiceBuilder\Parameter $parameter) {

        $i1 = '    ';//Indent 1
        $i2 = '        ';//Indent 1

        $text = '';

        $text .= sprintf(
            $i1."case ('%s'): {".PHP_EOL,
            $parameter->getName()
        );
        
        foreach ($parameter->getFilters() as $filter) {

            if (is_array($filter)) {
                $text .= $i2.'$args = [];'.PHP_EOL;

                if (isset($filter['args']) == true) {
                    if (is_array($filter['args']) == false) {
                        throw new \ArtaxServiceBuilder\APIBuilderException("Filter args should be an array instead received ".var_export($filter['args'],
                                true
                            )
                        );
                    }

                    // Convert complex filters that hold value place holders
                    foreach ($filter['args'] as $data) {
                        if ($data == '@value') {
                            $text .= $i2.'$args[] = $value;'.PHP_EOL;
                        }
                        elseif ($data == '@api') {
                            $text .= $i2."\$args[] = \$this->\$api;".PHP_EOL;
                        }
                        else {
                            //It should be a string
                            $text .= $i2."\$args[] = $data;".PHP_EOL;
                        }
                    }
                }

//                $text .= sprintf(
//                    //TODO - we can do better than call_user_func_array
//                    $i2.'$value = call_user_func_array(\'%s\', $args);'.PHP_EOL,
//                    $filter['method']
//                );

                //hard-code for now 2016-02-28
                $text .= sprintf(
                    $i2.'$value = call_user_func_array([$value, \'%s\'], $args);'.PHP_EOL,
                    $filter['method']
                );

            }
            else {
                //TODO - get rid of call_user_func
                $text .= sprintf(
                    $i2.'call_user_func(\'%s\', $value);'.PHP_EOL,
                    $filter
                );
            }
        }

        $text .= $i1.'    break;'.PHP_EOL;
        $text .= $i1.'}'.PHP_EOL;

        return $text;
    }
function generateParamFilterBlock ( \ ArtaxServiceBuilder \ Parameter $ parameter ) { $ i1 = '    ' ; //Indent 1 $ i2 = '        ' ; //Indent 1 $ text = '' ; $ text .= sprintf ( $ i1 . "case ('%s'): {" . PHP_EOL , $ parameter -> getName ( ) ) ; foreach ( $ parameter -> getFilters ( ) as $ filter ) { if ( is_array ( $ filter ) ) { $ text .= $ i2 . '$args = [];' . PHP_EOL ; if ( isset ( $ filter [ 'args' ] ) == true ) { if ( is_array ( $ filter [ 'args' ] ) == false ) { throw new \ ArtaxServiceBuilder \ APIBuilderException ( "Filter args should be an array instead received " . var_export ( $ filter [ 'args' ] , true ) ) ; } // Convert complex filters that hold value place holders foreach ( $ filter [ 'args' ] as $ data ) { if ( $ data == '@value' ) { $ text .= $ i2 . '$args[] = $value;' . PHP_EOL ; } elseif ( $ data == '@api' ) { $ text .= $ i2 . "\$args[] = \$this->\$api;" . PHP_EOL ; } else { //It should be a string $ text .= $ i2 . "\$args[] = $data;" . PHP_EOL ; } } } //                $text .= sprintf( //                    //TODO - we can do better than call_user_func_array //                    $i2.'$value = call_user_func_array(\'%s\', $args);'.PHP_EOL, //                    $filter['method'] //                ); //hard-code for now 2016-02-28 $ text .= sprintf ( $ i2 . '$value = call_user_func_array([$value, \'%s\'], $args);' . PHP_EOL , $ filter [ 'method' ] ) ; } else { //TODO - get rid of call_user_func $ text .= sprintf ( $ i2 . 'call_user_func(\'%s\', $value);' . PHP_EOL , $ filter ) ; } } $ text .= $ i1 . '    break;' . PHP_EOL ; $ text .= $ i1 . '}' . PHP_EOL ; return $ text ; }
Generate the code required to filter a parameter of the operation.
@param Parameter $parameter
@return string
@throws APIBuilderException
Generate the code required to filter a parameter of the operation .