You are here

function moopapi_create_args in Module Object Oriented Programming API 7

Same name and namespace in other branches
  1. 6.2 moopapi.module \moopapi_create_args()
  2. 6 moopapi.module \moopapi_create_args()
  3. 7.2 moopapi.module \moopapi_create_args()

API to create arguments' string.

Parameters

array $parameters:

boolean $clean:

Return value

arg_string

1 call to moopapi_create_args()
moopapi_wrap in ./moopapi.module
Api function that will create function wrapper to a class method

File

./moopapi.module, line 103

Code

function moopapi_create_args($parameters, $clean = FALSE) {
  $args = array();
  foreach ($parameters as $i => $parameter) {
    $prefix = '';
    if (!$clean) {
      $prefix = $parameter
        ->isPassedByReference() ? '&' : '';
    }
    $name = $parameter
      ->getName();
    $arg_definition = "{$prefix}\${$name}";
    if ($parameter
      ->isOptional()) {
      $default_value = $parameter
        ->getDefaultValue();
      $default_value = $default_value ? $default_value : 'NULL';
      $arg_definition .= "={$default_value}";
    }
    $args[$i] = $arg_definition;
  }
  $args = implode(', ', $args);
  return $args;
}