Helper to return cleaned passed arguments.

@param array $args
@return array
515806
public static function arguments(array $args) : array
    {
        putenv("CODGER_DRY=1");
        foreach ($args as $key => $value) {
            if ($value === '-w') {
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-o') {
                putenv("CODGER_OVERWRITE=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-d') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_DUMP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
            if ($value === '-s') {
                putenv("CODGER_OVERWRITE=0");
                putenv("CODGER_SKIP=1");
                putenv("CODGER_DRY=0");
                unset($args[$key]);
            }
        }
        return array_values($args);
    }
790959
protected static function getParams(array $arg_params)
    {
        $return = array();
        //validate params
        $data = array(
            'amount',
            'transaction_id',
            'customer_id',
            'security_token',
            'customer_ip'
        );
        foreach ($data as $key) {
            if(!empty($arg_params[$key])){
                $return[$key] = $arg_params[$key];
            }
        }

        return $return;
    }
379800
public function bootstrapGridFunction(array $args = []) {

        $output = [];

        $output[] = $this->bootstrapGridStackedFunction($args);
        $output[] = $this->bootstrapGridOffsetFunction($args);
        $output[] = $this->bootstrapGridPushFunction($args);
        $output[] = $this->bootstrapGridPullFunction($args);

        return trim(implode(" ", $output));
    }
1254847
protected function getFromMethod($args)
    {
        if (!$method = $this->getKeyMethod($args)) {
            return '';
        }

        array_shift($args);

        return call_user_func([$this, $method], ...$args);
    }
1137951
public function normalizeArgs(array $args): array
    {
        $normalized = [];

        foreach ($args as $arg) {
            if (\preg_match('/^\-\w{2,}/', $arg)) {
                $splitArg   = \implode(' -', \str_split(\ltrim($arg, '-')));
                $normalized = \array_merge($normalized, \explode(' ', '-' . $splitArg));
            } elseif (\preg_match('/^\-\-\w{2,}\=/', $arg)) {
                $normalized = \array_merge($normalized, explode('=', $arg));
            } else {
                $normalized[] = $arg;
            }
        }

        return $normalized;
    }
746021
private function level_and_channel_from_args( array $args ) {

		if ( ! $args ) {
			return [ '', '' ];
		}

		$level   = 0;
		$channel = '';

		if ( ! empty( $args[ 0 ] ) && is_scalar( $args[ 0 ] ) ) {
			$level = $args[ 0 ];
		}

		if ( ! empty( $args[ 1 ] ) && is_string( $args[ 1 ] ) ) {
			$channel = $args[ 1 ];
		}

		return [ $level, $channel ];
	}
1205521
private function escapeArgs(&$args) {
    $escaped = array();
    foreach ($args as $arg) {
      $escaped[] = escapeshellarg($arg);
    }
    return $escaped;
  }
961865
private function dumpArgs($args)
    {
        foreach ($args as $key => $arg) {
            if (is_object($arg)) {
                $v = '{' . get_class($arg) . '}';
            }
            else if (is_array($arg)) {
                $v = '[' . $this->dumpArgs($arg) . ']';
            }
            else if (is_string($arg)) {
                $v = '"' . (strlen($arg) <= 16 ? $arg : trim(substr($arg, 0, 15)) . '...') . '"';
            }
            else if (is_bool($arg)) {
                $v = $arg ? 'true' : 'false';
            }
            else if ($arg === null) {
                $v = 'null';
            }
            else {
                $v = $arg;
            }

            $args[$key] = is_string($key) ? '"' . $key . '" => ' . $v : $v;
        }

        return implode(', ', $args);
    }
859983
protected function processArguments($arguments)
    {
        if (false === is_array($arguments)) {
            return $arguments;
        }

        return array_map(function ($argument) {
            return (string) $argument;
        }, $arguments);
    }
1251044
protected function getSplatCallVars($args)
    {
        $isSplatCall = false;
        $variables = [];
        foreach ($args as $arg) {
            if ($arg->unpack) {
                $isSplatCall = true;
            }
            $variables[] = $arg->value;
        }
        if (! $isSplatCall) {
            return;
        }
        return $variables;
    }
334678
protected function colorArgs($args)
    {
        if ($args[0] != 'list' || count($args[2]) < 2) {
            return array(array('color', 0, 0, 0), 0);
        }
        list($color, $delta) = $args[2];
        $color = $this->assertColor($color);
        $delta = floatval($delta[1]);

        return array($color, $delta);
    }
751276
private function prepare($args)
    {
        $bindings = array();

        // Two parameters (key, value).
        if (count($args) == 2) {
            $bindings[$args[0]] = $args[1];
        }
        // Array of parameters.
        elseif (is_array($args[0])) {
            $bindings = $args[0];
        }

        return $bindings;
    }
100907
private function resolveArgs(array $args)
    {
        $resolved = [];
        foreach ($args as $argDefinition) {
            switch ($argDefinition['type']) {
                case 'lookup':
                    $resolved[] = $this->lookupRecursive($argDefinition['item']);
                    break;
                case 'value':
                    $resolved[] = $argDefinition['item'];
                    break;
            }
        }

        return $resolved;
    }
590006
protected function getServiceByArgs($args) {
		$args = $this->normalizeArgs($args);
		$id   = $this->getIdByArgs($args);
		$args = $this->processArgs($args);
			
		if (! isset($this->servicesByArgs[$id])) {
			$this->servicesByArgs[$id] = $this->initService($args);
		}

		return $this->servicesByArgs[$id];
	}
19324
private function formatArguments($arguments)
    {
        $result = [];
        foreach ($arguments as $key => $argument) {
            if (is_object($argument)) {
                $result[$key] = get_class($argument);
                continue;
            }

            if (is_array($argument)) {
                $result[$key] = $this->formatArguments($argument);
                continue;
            }

            $result[$key] = $argument;
        }

        return $result;
    }
560413
protected function setParameters($args)
    {
        if (count($args) < 1) {
            return [
                'parent' => $this->parents ? current($this->parents) : 0,
                'data' => $this->data,
            ];
        } elseif (count($args) == 1) {
            return [
                'parent' => reset($args),
                'data' => $this->data,
            ];
        } else {
            return [
                'data' => reset($args),
                'parent' => next($args),
            ];
        }
    }
931748
protected function getArgumentsAsString(array $args)
    {
        $result = [];
        $isNumeric = Jasny\is_numeric_array($args);
        $stringify = function ($input) {
            return sprintf("'%s'", addcslashes($input, "'"));
        };

        foreach ($args as $key => $arg) {
            switch (strtolower(gettype($arg))) {
                case 'string':
                    $string = $stringify($arg);
                    break;

                case 'object':
                    $string = get_class($arg);
                    break;

                case 'array':
                    $string = "[{$this->getArgumentsAsString($arg)}]";
                    break;

                case 'null':
                    $string = 'null';
                    break;

                case 'boolean':
                    $string = $arg ? 'true' : 'false';
                    break;

                case 'resource':
                    $string = sprintf('*%s', get_resource_type($arg));
                    break;

                default:
                    $string = $arg;
            }

            if ($isNumeric === false) {
                $result[] = is_string($key) === true ? $stringify($key) . ' => ' . $string : $string;
            } else {
                $result[] = $string;
            }
        }

        return join(', ', $result);
    }