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;
    }
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;
    }
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 ; }
Sets the value of attribute,
taking enums typecast into consideration

@param string $key Name of the attribute
@param mixed $value Value of the attribute to set
@return $this
Sets the value of attribute taking enums typecast into consideration