Current Path : /storage/v11800/lifespanstoresnew/public_html/wp-content/plugins/google-listings-and-ads/src/Shipping/ |
Linux v11800 5.3.0-1023-aws #25~18.04.1-Ubuntu SMP Fri Jun 5 15:19:18 UTC 2020 aarch64
|
Current File : /storage/v11800/lifespanstoresnew/public_html/wp-content/plugins/google-listings-and-ads/src/Shipping/ShippingRegion.php |
<?php
declare( strict_types=1 );
namespace Automattic\WooCommerce\GoogleListingsAndAds\Shipping;
defined( 'ABSPATH' ) || exit;
/**
* Class ShippingRegion
*
* @package Automattic\WooCommerce\GoogleListingsAndAds\Shipping
*
* @since 2.1.0
*/
class ShippingRegion {
/**
* @var string
*/
protected $id;
/**
* @var string
*/
protected $country;
/**
* @var PostcodeRange[]
*/
protected $postcode_ranges;
/**
* ShippingRegion constructor.
*
* @param string $id
* @param string $country
* @param PostcodeRange[] $postcode_ranges
*/
public function __construct( string $id, string $country, array $postcode_ranges ) {
$this->id = $id;
$this->country = $country;
$this->postcode_ranges = $postcode_ranges;
}
/**
* @return string
*/
public function get_id(): string {
return $this->id;
}
/**
* @return string
*/
public function get_country(): string {
return $this->country;
}
/**
* @return PostcodeRange[]
*/
public function get_postcode_ranges(): array {
return $this->postcode_ranges;
}
/**
* Generate a random ID for the region.
*
* For privacy reasons, the region ID value must be a randomized set of numbers (minimum 6 digits)
*
* @return string
*
* @throws \Exception If generating a random ID fails.
*
* @link https://support.google.com/merchants/answer/9698880?hl=en#requirements
*/
public static function generate_random_id(): string {
return (string) random_int( 100000, PHP_INT_MAX );
}
/**
* Returns the string representation of this object.
*
* @return string
*/
public function __toString() {
return $this->get_country() . join( ',', $this->get_postcode_ranges() );
}
}