-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbootstrap.hh
61 lines (51 loc) · 1.53 KB
/
bootstrap.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
<?hh
/**
* @copyright 2010-2015, The Titon Project
* @license http://opensource.org/licenses/bsd-license.php
* @link http://titon.io
*/
/**
* --------------------------------------------------------------
* Type Aliases
* --------------------------------------------------------------
*
* Defines type aliases that are used by the environment package.
*/
namespace Titon\Environment {
type ImmutableList = Vector<string>;
type ImmutableVariableMap = ImmMap<string, mixed>;
type VariableMap = Map<string, mixed>;
}
/**
* --------------------------------------------------------------
* Helper Functions
* --------------------------------------------------------------
*
* Defines global helper functions for common use cases.
*/
namespace {
use Titon\Context\Depository;
use Titon\Environment\Detector;
/**
* @see Titon\Environment\Detector::getVariable()
*/
function env(string $key): mixed {
return detector_context()->getVariable($key);
}
/**
* @see Titon\Environment\Detector::is()
*/
function is_env(string $key): bool {
return detector_context()->is($key);
}
/**
* Make and return a `Detector` instance from the depository.
*
* @return \Titon\Environment\Detector
*/
function detector_context(): Detector {
$detector = Depository::getInstance()->make('Titon\Environment\Detector');
invariant($detector instanceof Detector, 'Must be an environment Detector.');
return $detector;
}
}