public function getErrors($key = null) {
        if (isset($key)) {
            return !empty($this->errors[$key]) ? $this->errors[$key] : array();
        }
        else {
            return $this->errors;
        }
    }
public function getErrors($key = null) {
        if (isset($key)) {
            return !empty($this->errors[$key]) ? $this->errors[$key] : array();
        }
        else {
            return $this->errors;
        }
    }
public function getErrors ( $ key = null ) { if ( isset ( $ key ) ) { return ! empty ( $ this -> errors [ $ key ] ) ? $ this -> errors [ $ key ] : array ( ) ; } else { return $ this -> errors ; } }
Returns errors of the model state.

@param string $key If the key is specified, only errors for the specified key will be returned.

@return array
Returns errors of the model state .