summaryrefslogtreecommitdiff
path: root/src/Config.php
blob: 06b32d01196ee7076f4776985f13bcdc57bd5c22 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<?php

namespace ERPHP;

class Config
{
  public static function load(): void
  {
    $_ENV = array_replace_recursive(
      $_ENV,
      json_decode(file_get_contents(dirname(__DIR__) . "/config.json"), true) ?: []
    );
  }

  public static function get(string $key, mixed $default = null): mixed
  {
    return $_ENV[$key] ?? getenv($key) === false ? $default : getenv($key);
  }
}