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