J'ai un petit souci d'ordre pratique : je suis en train de coder un petit projet, mais
je ne sais pas comment appeler une classe.
Celle-ci est parente de toutes mes classes métiers, et sert à injecter rapidement toutes les dépendances.
En voici le code :
/**
* Lite Object
*
*
* @author Yohann Schwan <[email protected]>
* @copyright Copyright (c) 2007, 2010 Yohann SCHWAN
* @license http://gnu.org/licenses/gpl.txt GNU GPL
*/
class Lite_Object
{
/**
* Injection des dep.
*
* @param array $vars
* @return void
*/
final public function __construct(array $vars)
{
foreach($vars as $id => $value)
{
$this->$id = $value;
}
}
/**
* @return void
*/
public function init()
{
}
/**
* @param string $method
* @param array $args
* @return void
*/
public function __call($method, array $args)
{
throw new Lite_Exception_Undefined_Method(get_class($this) . '::' . $method, $args);
}
/**
* @param string $property
* @param mixed $value
* @return void
*/
public function __set($property, $value)
{
throw new Lite_Exception_Undefined_Property(get_class($this) . '::$' . $property, $value);
}
/**
* @param string $property
* @return void
*/
public function __get($property)
{
throw new Lite_Exception_Undefined_Property(get_class($this) . '::$' . $property);
}
}
Voila, j'ai appelé ça simplement "object", mais si quelqu'un avait un nom un peu plus parlant, ça m'arrangerait. Merci d'avance !