Bonjour à tous.
J'ai un problème de convention pour une classe PHP. Cette classe est censée représenter une entrée de log, caractérisée par un type (ERROR, WARNING ou INFO).
Le problème, c'est que je ne sais pas trop comment stocker cette liste de valeurs possibles, étant donné qu'il me semble qu'il n'est pas possible de définir un tableau en constante. Pour le moment, cette liste est stockée dans une variable, mais c'est pas super car c'est pas une variable...

Voici le code:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
class Event{
	// Properties declaration
	private $EXISTING_TYPES = array("ERROR", "WARNING", "INFO"); // Existing types of log
	private $type; // Type of the event (ERROR, WARNING, INFO).
	private $text; // Text of the event.
	private $date; // Date at which the event occured. (Unix format).
 
	// Functions declaration
 
	// Constructor, initialize an event with the current date.
	function __construct($type = NULL, $text = NULL){
		if(in_array($type, $this->EXISTING_TYPES)){ // If the type of event is valid\
			// Create the event
			$this->type = $type;
			$this->text = $text;
			$this->date = time();
 
		}else{
			$_SESSION['log']->addEvent("ERROR","Event type incorrect.");
			return false;
		}
	}
D'après vous quelle serait la méthode la plus propre pour stocker cette liste de valeur possible?

Merci!!
Nathan