2018-02-13 00:51:04 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Support;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* ICAO Helper Tools
|
|
|
|
*/
|
|
|
|
class ICAO
|
|
|
|
{
|
2018-02-13 10:58:23 +08:00
|
|
|
/**
|
|
|
|
* Create a random hex code. Eventually this may follow the format in:
|
|
|
|
* ICAO Aeronautical Telecommunications, Annex 10, Vol. III, chapter 9
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-02-13 10:58:23 +08:00
|
|
|
* @param null $country
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-08-27 02:50:08 +08:00
|
|
|
* @throws \Exception
|
2018-08-27 02:51:47 +08:00
|
|
|
*
|
|
|
|
* @return string
|
2018-02-13 10:58:23 +08:00
|
|
|
*/
|
2019-04-08 06:35:55 +08:00
|
|
|
public static function createHexCode($country = null): string
|
2018-02-13 10:58:23 +08:00
|
|
|
{
|
|
|
|
$bytes = random_bytes(4);
|
|
|
|
return bin2hex($bytes);
|
|
|
|
}
|
2018-02-13 00:51:04 +08:00
|
|
|
}
|