/** * Prompts the user for input, and returns it. * * @param string $prompt Prompt text. * @param mixed $options Array or string of options. * @param string $default Default input value. * @return Either the default value, or the user-provided input. * @access public */ function in($prompt, $options = null, $default = null) { if (!$this->interactive) { return $default; } $in = $this->Dispatch->getInput($prompt, $options, $default); if ($options && is_string($options)) { if (strpos($options, ',')) { $options = explode(',', $options); } elseif (strpos($options, '/')) { $options = explode('/', $options); } else { $options = array($options); } } if (is_array($options)) { while ($in === '' || $in !== '' && (!in_array(strtolower($in), $options) && !in_array(strtoupper($in), $options)) && !in_array($in, $options)) { $in = $this->Dispatch->getInput($prompt, $options, $default); } } return $in; }