/**
  * @param MessagePeer|null $peer
  *
  * @return MessagePeer
  */
 private function createServiceFromVirtual(MessagePeer $peer = null)
 {
     if ($peer instanceof Peer) {
         $details = $peer->getDetails();
         if (array_key_exists('host', $details)) {
             $peer = Peer::fromNormalized(array_merge($details, ['service' => $details['host']]));
         }
     }
     return $peer ?: Peer::fromNormalized(['identifier' => 'unknown', 'service' => 'Unknown']);
 }
Beispiel #2
0
 /**
  * @param array $normalized
  *
  * @return MessageProfile
  */
 public static function fromQueryResult(array $normalized)
 {
     if (!array_key_exists('message', $normalized)) {
         throw new \InvalidArgumentException('Missing the `message` attribute');
     }
     $normalizedMessage = $normalized['message'];
     $profile = new self(StringMessageIdentifier::fromString($normalizedMessage['identifier']), isset($normalized['sender']) ? Peer::fromNormalized($normalized['sender']) : null, isset($normalized['receiver']) ? Peer::fromNormalized($normalized['receiver']) : null, $normalizedMessage['context']);
     if (null !== ($timing = self::timingFromQuery($normalized))) {
         $profile = $profile->withTiming($timing);
     }
     if (isset($normalized['parent'])) {
         $parentIdentifier = StringMessageIdentifier::fromString($normalized['parent']['identifier']);
         $profile = $profile->withParentIdentifier($parentIdentifier);
         $profile->parent = $normalized['parent'];
     }
     $profile->message = $normalized['message'];
     return $profile;
 }