Exemplo n.º 1
0
 /**
  *  @see \DB\SQL\Mapper::__set($key, $value)
  *
  *  @throws FieldNotExistException
  *  @throws FieldInvalidException
  */
 public function __set($key, $value)
 {
     if (!array_key_exists($key, $this->properties)) {
         throw new FieldNotExistsException("{$key} does not exist.");
     }
     $class = sprintf("datatype\\%s", $this->properties[$key]["type"]);
     $instance = new $class();
     if (!$instance->validate($value, $this->properties[$key])) {
         throw new FieldInvalidException(print_r($value, true) . " is not allowed for field '{$key}'");
     }
     parent::__set($key, $value);
 }