2024-06-24 04:31:03 +02:00
|
|
|
<?php
|
2024-08-05 06:02:58 +02:00
|
|
|
/**
|
|
|
|
* Invoice Ninja (https://invoiceninja.com).
|
|
|
|
*
|
|
|
|
* @link https://github.com/invoiceninja/invoiceninja source repository
|
|
|
|
*
|
|
|
|
* @copyright Copyright (c) 2024. Invoice Ninja LLC (https://invoiceninja.com)
|
|
|
|
*
|
|
|
|
* @license https://www.elastic.co/licensing/elastic-license
|
|
|
|
*/
|
2024-06-24 04:31:03 +02:00
|
|
|
|
|
|
|
namespace App\DataProviders;
|
|
|
|
|
2024-08-22 08:45:06 +02:00
|
|
|
final class CAProvinces
|
|
|
|
{
|
2024-06-24 04:31:03 +02:00
|
|
|
/**
|
|
|
|
* The provinces and territories of Canada
|
|
|
|
*
|
|
|
|
* @var array
|
|
|
|
*/
|
|
|
|
protected static $provinces = [
|
|
|
|
'AB' => 'Alberta',
|
|
|
|
'BC' => 'British Columbia',
|
|
|
|
'MB' => 'Manitoba',
|
|
|
|
'NB' => 'New Brunswick',
|
|
|
|
'NL' => 'Newfoundland And Labrador',
|
|
|
|
'NS' => 'Nova Scotia',
|
|
|
|
'ON' => 'Ontario',
|
|
|
|
'PE' => 'Prince Edward Island',
|
|
|
|
'QC' => 'Quebec',
|
|
|
|
'SK' => 'Saskatchewan',
|
|
|
|
'NT' => 'Northwest Territories',
|
|
|
|
'NU' => 'Nunavut',
|
|
|
|
'YT' => 'Yukon'
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the name of the province or territory for a given abbreviation.
|
|
|
|
*
|
|
|
|
* @param string $abbreviation
|
|
|
|
* @return string
|
|
|
|
*/
|
2024-08-22 08:45:06 +02:00
|
|
|
public static function getName($abbreviation)
|
|
|
|
{
|
2024-06-24 04:31:03 +02:00
|
|
|
return self::$provinces[$abbreviation];
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get all provinces and territories.
|
|
|
|
*
|
|
|
|
* @return array
|
|
|
|
*/
|
2024-08-22 08:45:06 +02:00
|
|
|
public static function get()
|
|
|
|
{
|
2024-06-24 04:31:03 +02:00
|
|
|
return self::$provinces;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the abbreviation for a given province or territory name.
|
|
|
|
*
|
|
|
|
* @param string $name
|
|
|
|
* @return string
|
|
|
|
*/
|
2024-08-22 08:45:06 +02:00
|
|
|
public static function getAbbreviation($name)
|
|
|
|
{
|
2024-06-24 04:31:03 +02:00
|
|
|
return array_search(ucwords($name), self::$provinces);
|
|
|
|
}
|
|
|
|
}
|