/**
  * Create message from amqp envelope
  *
  * @param \AMQPEnvelope $envelope
  *
  * @return AmqpMessage
  */
 public static function createMessage(\AMQPEnvelope $envelope)
 {
     $properties = [];
     foreach (CustomAmqpMessage::getPropertyNames() as $name) {
         $properties[$name] = $envelope->{'get' . ucfirst($name)}();
     }
     return CustomAmqpMessage::fromProperties($properties);
 }
 /**
  * @param AmqpLibMessage $message
  *
  * @return AmqpMessage
  */
 public static function createMessage(AmqpLibMessage $message)
 {
     $properties = ['body' => $message->body];
     foreach (self::$PROPERTY_MAP as $name => $amqpLibName) {
         if ($message->has($amqpLibName)) {
             $properties[$name] = $message->get($amqpLibName);
         }
     }
     return CustomAmqpMessage::fromProperties($properties);
 }
 /**
  * @test create message with null properties
  */
 public function messageFromPropertiesWithNulls()
 {
     $mock = new AmqpMessageMock(true);
     $message = CustomAmqpMessage::fromProperties(['body' => $mock->getBody(), 'headers' => $mock->getHeaders(), 'contentType' => $mock->getContentType(), 'contentEncoding' => $mock->getContentEncoding(), 'messageId' => $mock->getMessageId(), 'appId' => $mock->getAppId(), 'userId' => $mock->getUserId(), 'priority' => $mock->getPriority()]);
     $this->assertEquals((new CustomAmqpMessage())->setBody($mock->getBody())->setHeaders($mock->getHeaders())->setContentType($mock->getContentType())->setContentEncoding($mock->getContentEncoding())->setPriority($mock->getPriority()), $message);
 }