street = $street; $this->street2 = $street2; $this->city = $city; $this->postal_code = $postal_code; $this->country = $country; } /** * Convert the object into a key=>value pair that can be used in HTTP requests. * * @return array */ public function toArray(): array { $streetAddress = [$this->street]; if( $this->street2 ){ $streetAddress[] = $this->street2; } return [ "street" => $streetAddress, "city" => $this->city, "postal_code" => $this->postal_code, "country" => $this->country ]; } }