location = $location; $this->shipping_rate = $shipping_rate; } /** * @return ShippingLocation */ public function get_location(): ShippingLocation { return $this->location; } /** * @return ShippingRate */ public function get_shipping_rate(): ShippingRate { return $this->shipping_rate; } /** * Specify data which should be serialized to JSON */ public function jsonSerialize(): array { $rate_serialized = $this->shipping_rate->jsonSerialize(); return array_merge( $rate_serialized, [ 'country' => $this->location->get_country(), ] ); } }