readArgument($observer, static::METHOD_CODE, MethodInterface::class); } /** * Reads payment model argument * * @param Observer $observer * @return InfoInterface * @since 100.1.0 */ protected function readPaymentModelArgument(Observer $observer) { return $this->readArgument($observer, static::MODEL_CODE, InfoInterface::class); } /** * Reads data argument * * @param Observer $observer * @return DataObject */ protected function readDataArgument(Observer $observer) { return $this->readArgument($observer, static::DATA_CODE, DataObject::class); } /** * Reads argument of certain type * * @param Observer $observer * @param string $key * @param string $type * @return mixed * @throws \LogicException */ protected function readArgument(Observer $observer, $key, $type) { $event = $observer->getEvent(); $argument = $event->getDataByKey($key); if (!$argument instanceof $type) { throw new \LogicException('Wrong argument type provided.'); } return $argument; } }