/**
  * {@inheritDoc}
  */
 public static function getStoreFormat(CompressorInterface $compressor)
 {
     if ($compressor->compressUTF8encoded()) {
         return new MessageStoreFormat(MessageStoreFormat::JSON);
     }
     // having compression means that non utf8 chars can appear, JSON don't support it so lets go with plain
     // at a higher level will be serialized
     return new MessageStoreFormat(MessageStoreFormat::PLAIN);
 }
Exemple #2
0
 /**
  * {@inheritDoc}
  */
 public static function fromStore($message, MessageStoreFormat $format, CompressorInterface $compressor)
 {
     $message = static::fromStoreDecode($message, $format);
     if (!isset($message[static::ID_KEY], $message[static::DATA_KEY])) {
         throw new InvalidArgumentException('SimpleMessage fromStore missing keys');
     }
     $error = isset($message[static::ERROR_KEY]) ? $message[static::ERROR_KEY] : static::DEFAULT_ERROR;
     $urgent = isset($message[static::URGENT_KEY]) ? $message[static::URGENT_KEY] : static::DEFAULT_URGENT;
     return new static($message[static::ID_KEY], $compressor->uncompress($message[static::DATA_KEY]), $error, $urgent);
 }