public function reverseTransform($address)
    {
        if (null === $address) {
            return null;
        }

        if (!$address instanceof ShipmentAddress) {
            throw new InvalidArgumentException("Expected instance of " . ShipmentAddress::class);
        }

        $data = [];

        foreach ($this->fields as $field) {
            $value = $this->accessor->getValue($address, $field);
            if (empty($value)) {
                continue;
            }

            if ($value instanceof CountryInterface) {
                $value = $value->getId();
            } elseif ($value instanceof StateInterface) {
                $value = $value->getId();
            } elseif ($value instanceof PhoneNumber) {
                $value = serialize($value);
            }

            $data[$field] = $value;
        }

        if (empty($data)) {
            return null;
        }

        return $data;
    }
public function reverseTransform($address)
    {
        if (null === $address) {
            return null;
        }

        if (!$address instanceof ShipmentAddress) {
            throw new InvalidArgumentException("Expected instance of " . ShipmentAddress::class);
        }

        $data = [];

        foreach ($this->fields as $field) {
            $value = $this->accessor->getValue($address, $field);
            if (empty($value)) {
                continue;
            }

            if ($value instanceof CountryInterface) {
                $value = $value->getId();
            } elseif ($value instanceof StateInterface) {
                $value = $value->getId();
            } elseif ($value instanceof PhoneNumber) {
                $value = serialize($value);
            }

            $data[$field] = $value;
        }

        if (empty($data)) {
            return null;
        }

        return $data;
    }
public function reverseTransform ( $ address ) { if ( null === $ address ) { return null ; } if ( ! $ address instanceof ShipmentAddress ) { throw new InvalidArgumentException ( "Expected instance of " . ShipmentAddress :: class ) ; } $ data = [ ] ; foreach ( $ this -> fields as $ field ) { $ value = $ this -> accessor -> getValue ( $ address , $ field ) ; if ( empty ( $ value ) ) { continue ; } if ( $ value instanceof CountryInterface ) { $ value = $ value -> getId ( ) ; } elseif ( $ value instanceof StateInterface ) { $ value = $ value -> getId ( ) ; } elseif ( $ value instanceof PhoneNumber ) { $ value = serialize ( $ value ) ; } $ data [ $ field ] = $ value ; } if ( empty ( $ data ) ) { return null ; } return $ data ; }
Transforms a shipment address in to an array.

@param ShipmentAddress $address

@return array|null
Transforms a shipment address in to an array .