public function setAttribute($key, $value)
    {
        // check if it's a enum
        if (isset($this->enums[$key]) && is_scalar($value)) {
            $enumClass = $this->enums[$key];
            $this->attributes[$key] = new $enumClass($value);
        } else {
            parent::setAttribute($key, $value);
        }
        return $this;
    }