proxitok/app/Helpers/Misc.php
2022-03-29 19:30:31 +02:00

30 lines
898 B
PHP

<?php
namespace App\Helpers;
class Misc {
static public function getCursor(): int {
return isset($_GET['cursor']) && is_numeric($_GET['cursor']) ? (int) $_GET['cursor'] : 0;
}
static public function getTtwid(): string {
return isset($_GET['cursor']) ? $_GET['cursor'] : '';
}
static public function url(string $endpoint = ''): string {
$protocol = isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http";
$root = $protocol . '://' . $_SERVER['HTTP_HOST'];
return $root . self::env('APP_PATH', '') . $endpoint;
}
static public function env(string $key, $default_value) {
return $_ENV[$key] ?? $default_value;
}
/**
* Returns absolute path for view
*/
static public function getView(string $template): string {
return __DIR__ . "/../../views/{$template}.latte";
}
}