kahlan\cli\CommandLine::_get PHP Method

_get() protected method

Helper for get().
protected _get ( string $name ) : array
$name string The name of the option.
return array The casted value.
    protected function _get($name)
    {
        $config = $this->option($name);
        list($key, $extra) = $this->_splitOptionName($name);
        if ($extra === '' && $config['group']) {
            $result = [];
            if (!isset($this->_values[$key])) {
                return $result;
            }
            foreach ($this->_values[$key] as $extra => $value) {
                $result[$extra] = $this->_get($name . ':' . $extra);
            }
            return $result;
        } else {
            $value = isset($this->_values[$key][$extra]) ? $this->_values[$key][$extra] : $config['default'];
        }
        $casted = $this->cast($value, $config['type'], $config['array']);
        if (!isset($config['value'])) {
            return $casted;
        }
        if (is_callable($config['value'])) {
            return array_key_exists($key, $this->_values) ? $config['value']($casted, $name, $this) : $casted;
        }
        return $config['value'];
    }