forked from nostriphant/transpher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bootstrap.php
42 lines (33 loc) · 1.06 KB
/
bootstrap.php
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
<?php
require_once __DIR__ . '/vendor/autoload.php';
define('ROOT_DIR', __DIR__);
is_dir(ROOT_DIR . '/logs') || mkdir(ROOT_DIR . '/logs');
$dotenv_file = ROOT_DIR . '/.env';
is_file($dotenv_file) || touch($dotenv_file);
$dotenv = Dotenv\Dotenv::createMutable(dirname($dotenv_file));
$dotenv->load();
if (function_exists('array_find') === false) {
/**
* PHP 8.4 compat
* @param array $array
* @param callable $callback
* @return mixed
*/
function array_find(array $array, callable $callback): mixed {
foreach ($array as $key => $value) {
if ($callback($value, $key)) {
return $value;
}
}
return null;
}
}
function file_append_contents(string $filename, string $contents): int {
$handle = fopen($filename, 'a');
$written = fwrite($handle, $contents);
fclose($handle);
return $written !== false ? $written : 0;
}
function in_range(string|int|float $value, string|int|float $start, string|int|float $end): bool {
return in_array($value, range($start, $end));
}