Neos\Flow\Cli\RequestBuilder::getValueOfCurrentCommandLineOption PHP Method

getValueOfCurrentCommandLineOption() protected method

Returns the value of the first argument of the given input array. Shifts the parsed argument off the array.
protected getValueOfCurrentCommandLineOption ( string $currentArgument, array &$rawCommandLineArguments, string $expectedArgumentType ) : string
$currentArgument string The current argument
$rawCommandLineArguments array
$expectedArgumentType string The expected type of the current argument, because booleans get special attention
return string The value of the first argument
    protected function getValueOfCurrentCommandLineOption($currentArgument, array &$rawCommandLineArguments, $expectedArgumentType)
    {
        if (!isset($rawCommandLineArguments[0]) && strpos($currentArgument, '=') === false || isset($rawCommandLineArguments[0]) && $rawCommandLineArguments[0][0] === '-' && strpos($currentArgument, '=') === false) {
            return true;
        }
        if (strpos($currentArgument, '=') === false) {
            $possibleValue = trim(array_shift($rawCommandLineArguments));
            if (strpos($possibleValue, '=') === false) {
                if ($expectedArgumentType !== 'boolean') {
                    return $possibleValue;
                }
                if (array_search($possibleValue, ['on', '1', 'y', 'yes', 'true', 'TRUE']) !== false) {
                    return true;
                }
                if (array_search($possibleValue, ['off', '0', 'n', 'no', 'false', 'FALSE']) !== false) {
                    return false;
                }
                array_unshift($rawCommandLineArguments, $possibleValue);
                return true;
            }
            $currentArgument .= $possibleValue;
        }
        $splitArgument = explode('=', $currentArgument, 2);
        while ((!isset($splitArgument[1]) || trim($splitArgument[1]) === '') && count($rawCommandLineArguments) > 0) {
            $currentArgument .= array_shift($rawCommandLineArguments);
            $splitArgument = explode('=', $currentArgument);
        }
        $value = isset($splitArgument[1]) ? $splitArgument[1] : '';
        return $value;
    }