for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/*
* This file is part of the Borobudur-Bus package.
*
* (c) Hexacodelabs <http://hexacodelabs.com>
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Borobudur\Bus\Message;
use Borobudur\Bus\Exception\InvalidArgumentException;
/**
* @author Iqbal Maulana <[email protected]>
* @created 10/12/15
trait MessageMapperTrait
{
* Factory create object from message.
* @param mixed $message
* @return static
public static function createFrom($message)
return MessageMapperBuilder::create(get_called_class(), $message);
}
* Factory create
* @param string $method
public static function factory($method, $message)
return MessageMapperBuilder::call(get_called_class(), $method, $message);
* Map message to object.
* @return MessageMapperDispatcher
public function from($message)
if (!is_object($message)) {
throw new InvalidArgumentException(sprintf('Message should be object, "%s" given.', gettype($message)));
return new MessageMapperDispatcher($message, $this);