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;
use ReflectionObject;
/**
* @author Iqbal Maulana <[email protected]>
* @created 10/12/15
class MessageMapperDispatcher
{
* @var array
private $data = array();
* @var mixed
private $object;
* @var ReflectionObject
private $reflection;
* Constructor.
* @param mixed $data
* @param mixed $object
public function __construct($data, $object)
$this->data = $data;
$data
array
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..
$this->object = $object;
$this->reflection = new ReflectionObject($object);
}
* Dispatch a method.
* @param string $method
* @return mixed
public function dispatch($method)
$this->assertThatMethodExist($method);
$method = $this->reflection->getMethod($method);
$arguments = MessageMapperBuilder::normalizeParameters($method->getParameters(), $this->data);
return $method->invokeArgs($this->object, $arguments);
* Assert that method is exist.
private function assertThatMethodExist($method)
if (!method_exists($this->object, $method)) {
throw new InvalidArgumentException(
sprintf(
'Method "%s" on class "%s" not exist.',
$method,
get_class($this->object)
)
);
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..