8,7 → 8,7 |
/** |
* Tableau associatif stockant les variables |
*/ |
private $aso_stock = array(); |
private $stockage = array(); |
/** |
* La classe registre se contient elle-même, (pour le pattern singleton) |
*/ |
17,8 → 17,7 |
/** |
* Constructeur par défaut, privé, car on accède à la classe par le getInstance |
*/ |
private function __construct() |
{ |
private function __construct() { |
$registre = $this; |
} |
|
26,8 → 25,7 |
* Fonction qui renvoie l'instance de classe en assurant son unicité, c'est l'unique méthode qui doit être |
* utilisé pour récupérer l'objet Registre |
*/ |
public static function getInstance() |
{ |
public static function getInstance() { |
if (self::$registre instanceof Registre) { |
return self::$registre; |
} |
40,14 → 38,13 |
* @param string l'intitulé sous lequel l'objet sera conservé |
* @param mixed l'objet à conserver |
*/ |
function set($intitule, $objet) |
{ |
if (is_array($objet) && isset($this->aso_stock[$intitule])) { |
$this->aso_stock[$intitule] = array_merge((array)$this->aso_stock[$intitule], (array)$objet); |
public function set($intitule, $objet) { |
if (is_array($objet) && isset($this->stockage[$intitule])) { |
$this->stockage[$intitule] = array_merge((array) $this->stockage[$intitule], (array) $objet); |
$message = "Le tableau $intitule présent dans le registre a été fusionné avec un nouveau tableau de même intitulé !"; |
trigger_error($message, E_USER_WARNING); |
} else { |
$this->aso_stock[$intitule] = $objet; |
$this->stockage[$intitule] = $objet; |
} |
} |
|
55,10 → 52,9 |
* Renvoie l'objet associé à l'intitulé donné en paramètre |
* @return mixed l'objet associé à l'intitulé ou null s'il n'est pas présent |
*/ |
function get($intitule) |
{ |
if (isset($this->aso_stock[$intitule])) { |
return $this->aso_stock[$intitule]; |
public function get($intitule) { |
if (isset($this->stockage[$intitule])) { |
return $this->stockage[$intitule]; |
} |
return null; |
} |
66,10 → 62,9 |
/** |
* Détruit l'objet associé à l'intitulé, n'a pas d'effet si il n'y a pas d'objet associé |
*/ |
function detruire($intitule) |
{ |
if (isset($this->aso_stock[$intitule])) { |
unset($this->aso_stock[$intitule]); |
public function detruire($intitule) { |
if (isset($this->stockage[$intitule])) { |
unset($this->stockage[$intitule]); |
} |
} |
|
77,9 → 72,8 |
* Teste si un objet est présent sous un intitulé donné |
* @return boolean true si un objet associé à cet intitulé est présent, false sinon |
*/ |
public function etrePresent($intitule) |
{ |
if(isset($this->aso_stock[$intitule])){ |
public function existe($intitule) { |
if(isset($this->stockage[$intitule])){ |
return true; |
} |
return false; |