Page MenuHomeDevCentral

Environment.php
No OneTemporary

Environment.php

<?php
namespace Keruald\OmniTools\OS;
use InvalidArgumentException;
class Environment {
public static function has (string $key) : bool {
return array_key_exists($key, $_ENV)
|| array_key_exists($key, $_SERVER);
}
/**
* @throws InvalidArgumentException
*/
public static function get (string $key) : string {
if (!self::has($key)) {
throw new InvalidArgumentException("Key not found: $key");
}
return $_ENV[$key] ?? $_SERVER[$key];
}
public static function getOr (string $key, string $default) : string {
return $_ENV[$key] ?? $_SERVER[$key] ?? $default;
}
}

File Metadata

Mime Type
text/x-php
Expires
Fri, Feb 28, 21:39 (1 d, 5 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2435869
Default Alt Text
Environment.php (671 B)

Event Timeline