protected function currentEnvironment($environment = null, $default = 'development')
    {
        $current = ($environment === null) ? $default : $environment;
        if (empty($environment)) {
            foreach ($this->environments as $name => $config) {
                if ($this->_match($name, $config['params'])) {
                    $current = $name;
                    break;
                }
            }
        }

        return $current;
    }