protected function _match($environment, $params)
    {
        $cakeEnv = env('CAKE_ENV');
        if (!empty($cakeEnv)) {
            return env('CAKE_ENV') == $environment;
        }

        if (is_bool($params)) {
            return $params;
        }

        if (is_callable($params) || (is_string($params) && function_exists($params))) {
            return $params();
        }

        foreach ($params as $param => $value) {
            if (function_exists($param)) {
                $match = call_user_func($param, $value);
            } elseif (is_array($value)) {
                $match = in_array(env($param), $value);
            } else {
                $match = (env($param) === $value);
            }

            if (!$match) {
                return false;
            }
        }
        return true;
    }