You are here

function coder_upgrade_array_to_preg in Coder 7

Same name and namespace in other branches
  1. 7.2 coder_upgrade/conversions/call.inc \coder_upgrade_array_to_preg()

Returns a preg string for the nomask parameter.

Parameters

PGPOperand $nomask:

Return value

string

1 call to coder_upgrade_array_to_preg()
coder_upgrade_upgrade_call_file_scan_directory_alter in coder_upgrade/conversions/call.inc
Implements hook_upgrade_call_file_scan_directory_alter().

File

coder_upgrade/conversions/call.inc, line 1598
Provides conversion routines applied to function calls.

Code

function coder_upgrade_array_to_preg($operand) {
  cdp(__FUNCTION__);
  $defaults = array(
    '.',
    '..',
    'CVS',
  );
  $current = $operand->values
    ->first();
  while ($current->next != NULL) {
    if ($current->type == 'value') {
      $values[] = trim($current->data
        ->toString(), "'\"");
    }
    $current = $current->next;
  }
  $defaults = array_diff($defaults, $values);
  if (empty($defaults)) {
    return "'/(\\.\\.?|CVS)\$/'";
  }
  $strings = array();
  foreach ($values as $value) {
    $strings[] .= str_replace('.', '\\.', $value);
  }
  return "'/(" . implode('|', $strings) . ")/'";
}