steefdw / airports
机场
v0.1.1
2024-06-27 14:46 UTC
Requires
- php: ^8.2
- nesbot/carbon: ^3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11
- phpmd/phpmd: ^2.13
- phpstan/phpstan: ^1.8.8
- phpunit/phpunit: ^9.5.25
- rector/rector: ^1.0
- squizlabs/php_codesniffer: ^3.7.1
This package is not auto-updated.
Last update: 2024-09-20 14:05:09 UTC
README
受CGP Grey的视频启发: ✈️ 机场代码的疯狂混乱!✈️
安装
composer require steefdw/airports
用法
通过IATA代码获取机场
$amsterdam = Airports::getAirport('AMS'); // Steefdw\Airports\Airport^ { // +icao: "EHAM" // +iata: "AMS" // +name: "Amsterdam Airport Schiphol" // +city: "Amsterdam" // +state: "North-Holland" // +country: "NL" // +elevation: -11 // +lat: 52.3086013794 // +lon: 4.7638897896 // +timezone: "Europe/Amsterdam" // }
获取两个机场之间的距离
$amsterdam = Airports::getAirport('AMS'); $barcelona = Airports::getAirport('BCN'); $distance = $amsterdam->getDistance($barcelona); // 1241.0765638345 (km)
获取两个机场之间的时差
$amsterdam = Airports::getAirport('AMS'); $london = Airports::getAirport('LTN'); $timeDiff = $amsterdam->getTimeDiff($london); // -1 (hour)
获取一组机场数组
Airports::getAirports(); // get all ~29k airports in the world Airports::getIataAirports(); // only the 7780 airports that have a three-letter IATA code. Airports::getAirportsByCountryCode('nl'); // only get the 27 airports in the Netherlands