0; } /** * Lists the messages that are currently available. * * @return array The messages that are currently set. */ public function listMessages() { return $GLOBALS[ 'whip_messages' ]; } /** * Deletes all messages. */ public function deleteMessages() { unset( $GLOBALS[ 'whip_messages' ] ); } /** * Gets the latest message. * * @return Whip_Message The message. Returns a NullMessage if none is found. */ public function getLatestMessage() { if ( ! $this->hasMessages() ) { return new Whip_NullMessage(); } $messages = $this->sortByVersion( $this->listMessages() ); $this->deleteMessages(); return array_pop( $messages ); } /** * Sorts the list of messages based on the version number. * * @param array $messages The list of messages to sort. * * @return array The sorted list of messages. */ private function sortByVersion( array $messages ) { uksort( $messages, 'version_compare' ); return $messages; } }