Paaxio 1.0
Plateforme de streaming musical - SAE IUT Bayonne
Chargement...
Recherche...
Aucune correspondance
constantes.class.php
Aller à la documentation de ce fichier.
1<?php
8{
12 private static ?Constantes $instance = null;
13
17 private $config;
18
24 private function __construct()
25 {
26 try {
27 $json = file_get_contents(__DIR__ . "/../config/config.json");
28 $this->config = json_decode($json, true);
29 } catch (Exception $e) {
30 die('Récupération du fichier de configuration échouer: ' . $e->getMessage());
31 }
32 }
33
38 public static function getInstance(): Constantes
39 {
40 if (self::$instance == null) {
41 self::$instance = new Constantes();
42 }
43 return self::$instance;
44 }
45
50 public function getConfig(): array
51 {
52 return $this->config;
53 }
54
58 private function __clone() {}
59
64 public function __wakeup()
65 {
66 throw new Exception("Un singleton ne doit pas être deserialisé.");
67 }
68}
69
__clone()
Empêche le clonage du singleton.
getConfig()
Retourne le tableau de configuration complet.
__construct()
Constructeur privé pour empêcher l'instanciation directe.
static getInstance()
Retourne l'instance unique de la classe Constantes (pattern Singleton).
__wakeup()
Empêche la désérialisation du singleton.
static Constantes $instance