/** * Get the extension used by the view file. * * @param string $path * * @return string|null */ protected function getExtension(string $path) { $extensions = array_keys($this->extensions); return Arr::first($extensions, function ($key, $value) use($path) { return Str::endsWith($path, $value); }); }
/** * Parse options. * * @param string $token * * @return \Viserio\Console\Input\InputOption */ protected function parseOption(string $token) : InputOption { $token = trim($token, '[]'); // Shortcut [-y|--yell] if (strpos($token, '|') !== false) { list($shortcut, $token) = explode('|', $token, 2); $shortcut = ltrim($shortcut, '-'); } else { $shortcut = null; } $name = ltrim($token, '-'); if (Str::endsWith($token, '=]*')) { $mode = InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY; $name = substr($name, 0, -3); } elseif (Str::endsWith($token, '=')) { $mode = InputOption::VALUE_REQUIRED; $name = rtrim($name, '='); } else { $mode = InputOption::VALUE_NONE; } return new InputOption($name, $shortcut, $mode); }