render($template, $data); } /** * Returns response object * * @return Response */ function response(): Response { return Flight::response(); } /** * Returns app object * * @return Engine */ function app(): Engine { return Flight::app(); } /** * Returns any value as boolean * * @param mixed $value * @return bool */ function bool(mixed $value): bool { if (is_bool($value)) { return $value; } if (is_object($value)) { return true; } if (is_string($value)) { return match ($value = trim($value)) { '1', 'yes', 'true' => true, '0', 'no', 'false' => false, default => empty($value), }; } if ($is_resource = is_resource($value)) { return $is_resource; // false if closed } return !empty($value); } /** * Get config values * * @param string $key * @param mixed|null $default * @return mixed */ function config(string $key, mixed $default = null): mixed { $config = Flight::get('config'); if (isset($config["flight.$key"])) { return $config["flight.$key"]; } if (isset($config[$key])) { return $config[$key]; } $config = Arr::undot($config); if (Arr::has($config, $key)) { return Arr::get($config, $key); } return $default; }