omisai/php-continents

PHP 提供大洲信息的软件包

1.1.0 2024-03-27 22:06 UTC

This package is auto-updated.

Last update: 2024-09-27 23:06:57 UTC


README

Latest Stable Version Latest Unstable Version License PHP Version Require

PHP Continents Package

PHP Continents Package 提供了一种方便且面向对象的方法来处理大洲数据。旨在轻松地将大洲信息集成到任何 PHP 应用程序中。此软件包提供了对大洲名称、非标准化 alpha-2 代码和联合国 M.49 数字代码的轻松访问。最终,还将提供更详细的地理数据,如子区域和额外地区。

特性

  • 轻松检索大洲名称和代码。
  • 面向对象编程 (OOP) 方法,以便更好地管理和集成数据。
  • 轻量级且易于集成到任何 PHP 项目中。(8.1+)
  • 目前支持英语、匈牙利语、德语、西班牙语、意大利语和法语。
  • 未来支持子区域和多个地区,使其适用于国际应用程序。

安装

可以通过 Composer 轻松安装 PHP Continents Package。

composer require omisai/php-continents

使用

安装软件包后,您就可以开始处理大洲数据了。您可以使用任何大洲模型或通过 Collection 访问所有模型。

/**
 * Access through the Collection
 *
 * Consider using the Collection class, if you
 * plan to register it to a service container.
 * It eagerly loads all the continents.
 */
use Omisai\Continents\Collection;

$collection = new Collection();
$continents = $collection->getContinents();

/**
 * Shorthand to use the default english locale
 */
$continents[0]->name; // "Asia"

/**
 * Or using different locale
 */
$continents[0]->getName('fr'); // "Asie"


/**
 * Search for continent based on alpha-2 code
 */
$collection->getContinentByCode('OC'); // Omisai\Continents\Models\Oceania

/**
 * Search for continent based on UN M.49 numeric code
 */
$collection->getContinentByNumeric('010'); // Omisai\Continents\Models\Antarctica


/**
 * Use any continent directly
 */
use Omisai\Continents\Models\Europe;

$europe = new Europe();
$europe->numeric; // "150"
$europe->code; // "EU"

更新日志

有关最近更改的更多信息,请参阅 更新日志

贡献

有关详细信息,请参阅 贡献指南

测试

./vendor/bin/pest

# or

composer test

安全

如果您发现任何安全相关的问题,请通过电子邮件 security@omisai.com 联系我们,而不是使用问题跟踪器。

许可证

MIT 许可证 (MIT)。有关更多信息,请参阅 许可证文件