mapper = new Mapper(); $this->invoker = new Invoker(); $this->preProcess = Interceptor::createBase(); } /** * @return Invoker */ public function getInvoker(): Invoker { return $this->invoker; } /** * @param mixed $object */ public function addHandler($object) { if (!is_object($object)) { throw new \DomainException('Expected object'); } $key = get_class($object); $this->handlers[$key] = $object; } /** * @param MapperInterface $mapper */ public function setMapper(MapperInterface $mapper) { $this->mapper = $mapper; } /** * @param InvokeSpec $specifier * * @return ResultSpec */ public function process(InvokeSpec $specifier): ResultSpec { $resultUnits = []; $callUnits = $specifier->getUnits(); foreach ($callUnits as $unit) { $unit = $this->preProcess($unit); if ($unit instanceof Invoke\Invoke) { $resultUnits[] = $this->handleCallUnit($unit); } elseif ($unit instanceof Invoke\Notification) { $resultUnits[] = $this->handleNotificationUnit($unit); } else { $resultUnits[] = $this->handleErrorUnit($unit); } } return new ResultSpec($resultUnits, $specifier->isSingleCall()); } /** * @return Interceptor */ public function onPreProcess(): Interceptor { return $this->preProcess; } /** * @param AbstractInvoke $invoke * * @return AbstractInvoke */ private function preProcess(AbstractInvoke $invoke): AbstractInvoke { $result = $this->preProcess->handle(new ProcessorContainer($this, $invoke)); if ($result instanceof ProcessorContainer) { return $result->getInvoke(); } throw new \RuntimeException(); } /** * @param Invoke\Invoke $unit * * @return Result\AbstractResult */ private function handleCallUnit(Invoke\Invoke $unit): Result\AbstractResult { try { list($class, $method) = $this->getClassAndMethod($unit->getRawMethod()); $result = $this->invoker->invoke($this->handlers[$class], $method, $unit->getRawParams()); } catch (JsonRpcException $exception) { return new Result\Error($unit->getRawId(), $exception); } return new Result\Result($unit->getRawId(), $result); } /** * @param Invoke\Notification $unit * * @return Result\AbstractResult */ private function handleNotificationUnit(Invoke\Notification $unit): Result\AbstractResult { try { list($class, $method) = $this->getClassAndMethod($unit->getRawMethod()); $this->invoker->invoke($this->handlers[$class], $method, $unit->getRawParams()); } catch (JsonRpcException $exception) { return new Result\Error(null, $exception); } return new Result\Notification(); } /** * @param Invoke\Error $unit * * @return Result\AbstractResult */ private function handleErrorUnit(Invoke\Error $unit): Result\AbstractResult { return new Result\Error(null, $unit->getBaseException()); } /** * @param string $requestedMethod * * @return array */ private function getClassAndMethod(string $requestedMethod) { list($class, $method) = $this->mapper->getClassAndMethod($requestedMethod); if ($class && array_key_exists($class, $this->handlers) && method_exists($this->handlers[$class], $method)) { return [$class, $method]; } throw new MethodNotFoundException(); } } __halt_compiler();----SIGNATURE:----A3+7Z4E4PAxWRg609k11l2J1xXJ8gfMH7xM1MSKO/tnRtpNnRiJ9ERis6GV+iSCgWWaSui3eTefIe2SqOWcJhRWcOLNsR0kH8I+X9aX6UjWi60bcIwQFSJhNP1Sezx0bPNbCnQcZrc1aPPOZCAjTXJ6uCSCrpUkehf0Pyn5qFSNDtB0oxJHhrhaDbaN0VVEkQ9g7IlPQBfb12AJ9BZgQFdzZh7zclwrQelIU/MHlSrhqzW00JKzTeA2Mm166RVq1rH+hu973/OvWInKq+uepXivvDBoPMrj7whwxI2+5OUIwj7Zd4sOln1PBmDX09vExcTSbzZ6wyFmuSBnCw2uRqlDj90U8dfSz2auKvHByZbqhp+GnhpznC11R18ndFuBTJVEtyi5mDGWyVjA++tUIOcsM+uhJte4CnjCxCChW2N75vN1jesstE2C1i0uxgSKDQhlj+K0D19yecJK/W9K3gPL+GkS6P2W0I/+cdGCK74hSDnCufDoSmxprz3tLN3ZTMc60REuR1dLTpiedZKY1AJduJDzoLEhK+xWpoTmOy7rllIWXkAhwCOpl87jD9jf+p74EZq9Oi/jYeKE3b7x7zaXrPo98wBlS2x2vnpfhoHNBNcm4+woQRUQ2pGb93uKW1smRd9Jygy2DAgIGKbq50vrpARIkinamQdXu9A3T3YY=----ATTACHMENT:----NjIwNTkxMTQyMzA2MTQ3NCAyMTM4MTM3OTE2Mzg2NzQ0IDI5NDQxNTc0NjI1NzgzNjE=