name = $name; } public function getName() { return $this->name; } // Autres méthodes... } // abstract class AbstractField { // protected $name; // protected $value; // protected $attributes; // protected $errors = []; // protected $validators = []; // public function __construct($name, $value = '', $attributes = []) { // $this->name = $name; // $this->value = $value; // $this->attributes = $attributes; // } // public function getName() { // return $this->name; // } // public function getValue() { // return $this->value; // } // public function setValue($value) { // $this->value = $value; // } // public function addValidator(callable $validator) { // $this->validators[] = $validator; // return $this; // } // public function isValid() { // foreach ($this->validators as $validator) { // if (!$validator($this->value)) { // return false; // } // } // return true; // } // public function getErrors() { // return $this->errors; // } // public function addError($error) { // $this->errors[] = $error; // } // public function getAttributesAsString() { // $attributesStr = ''; // foreach ($this->attributes as $key => $value) { // $attributesStr .= " $key=\"$value\""; // } // return $attributesStr; // } // abstract public function render(); // }