src/Message/MessageFactory.php
private function consume(array $data, array $context)
    {
        foreach ($context as $property => $value) {
            $sanitized = $this->validateValue($value);
            if ($sanitized === null) {
                continue;
            }

            if (in_array($property, [MessageInterface::SERVER_IP, MessageInterface::USER_IP], true)) {
                try {
                    $ip = new IP($value);
                    $value = $ip->getShortAddress();
                } catch (InvalidIpAddressException $e) {
                    $value = '0.0.0.0';
                }
            }

            if (in_array($property, $this->knownProperties, true)) {
                $data[$property] = $sanitized;

            } else {
                $data[MessageInterface::CONTEXT][$property] = $sanitized;
            }
        }

        return $data;
    }
private function consume(array $data, array $context)
    {
        foreach ($context as $property => $value) {
            $sanitized = $this->validateValue($value);
            if ($sanitized === null) {
                continue;
            }

            if (in_array($property, [MessageInterface::SERVER_IP, MessageInterface::USER_IP], true)) {
                try {
                    $ip = new IP($value);
                    $value = $ip->getShortAddress();
                } catch (InvalidIpAddressException $e) {
                    $value = '0.0.0.0';
                }
            }

            if (in_array($property, $this->knownProperties, true)) {
                $data[$property] = $sanitized;

            } else {
                $data[MessageInterface::CONTEXT][$property] = $sanitized;
            }
        }

        return $data;
    }
private function consume ( array $ data , array $ context ) { foreach ( $ context as $ property => $ value ) { $ sanitized = $ this -> validateValue ( $ value ) ; if ( $ sanitized === null ) { continue ; } if ( in_array ( $ property , [ MessageInterface :: SERVER_IP , MessageInterface :: USER_IP ] , true ) ) { try { $ ip = new IP ( $ value ) ; $ value = $ ip -> getShortAddress ( ) ; } catch ( InvalidIpAddressException $ e ) { $ value = '0.0.0.0' ; } } if ( in_array ( $ property , $ this -> knownProperties , true ) ) { $ data [ $ property ] = $ sanitized ; } else { $ data [ MessageInterface :: CONTEXT ] [ $ property ] = $ sanitized ; } } return $ data ; }
Parse the provided context data and add it to the message payload

@param mixed[] $data
@param mixed[] $context

@return mixed[]
Parse the provided context data and add it to the message payload