services[$service_name] = $callable; } // Note args may be an object or an array maybe more...! public function get_service(string $service_name, $args = []) { if (!array_key_exists($service_name, $this->services)) { throw new \Exception("The Service: {$service_name} does not exists."); } return $this->services[$service_name]($args); } public function __set(string $service_name, callable $callable): void { $this->register($service_name, $callable); } public function __get(string $service_name) { return $this->get_service($service_name); } public function list_services_as_array(): array { return array_keys($this->services); } public function list_services_as_string(): string { return implode(',', array_keys($this->services)); } } // Initialize our Dependency Injector registry::set('di', new di()); // Setup php for working with Unicode data, if possible if (extension_loaded('mbstring')) { mb_internal_encoding('UTF-8'); mb_http_output('UTF-8'); mb_language('uni'); setlocale(LC_ALL, "en_US.UTF-8"); }