-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #27 from codeliner/feature/message-converter
Add message converter
- Loading branch information
Showing
2 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/common. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 7/26/15 - 3:27 PM | ||
*/ | ||
|
||
namespace Prooph\Common\Messaging; | ||
|
||
/** | ||
* Interface MessageConverter | ||
* | ||
* A message converter is able to convert a DomainMessage into an array | ||
* | ||
* @package Prooph\Common\Messaging | ||
* @author Alexander Miertsch <[email protected]> | ||
*/ | ||
interface MessageConverter | ||
{ | ||
/** | ||
* @param DomainMessage $domainMessage | ||
* @return array | ||
*/ | ||
public function convertToArray(DomainMessage $domainMessage); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
/* | ||
* This file is part of the prooph/common. | ||
* (c) 2014-2015 prooph software GmbH <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* Date: 7/26/15 - 3:30 PM | ||
*/ | ||
namespace Prooph\Common\Messaging; | ||
|
||
/** | ||
* Class NoOpMessageConverter | ||
* | ||
* The NoOpMessageConverter does not perform any conversion logic. | ||
* It simply returns DomainMessage::toArray. | ||
* The converter acts as a default implementation but allows replacement | ||
* with a custom converter using some special logic. | ||
* | ||
* @package Prooph\Common\Messaging | ||
* @author Alexander Miertsch <[email protected]> | ||
*/ | ||
final class NoOpMessageConverter implements MessageConverter | ||
{ | ||
|
||
/** | ||
* @param DomainMessage $domainMessage | ||
* @return array | ||
*/ | ||
public function convertToArray(DomainMessage $domainMessage) | ||
{ | ||
return $domainMessage->toArray(); | ||
} | ||
} |