dbizapps / utilities
PHP 应用程序的常用工具
v0.1.1
2021-09-23 21:28 UTC
Requires (Dev)
- phpunit/phpunit: 10.0.x-dev
This package is auto-updated.
Last update: 2024-09-24 04:10:33 UTC
README
此包为 PHP 应用程序提供常用工具功能。
一组工具类专注于国际组件Unicode(ICU)数据集。以下组件,默认ICU数据集作为配置文件提供
- 地区
- 货币
- 时区
在特定用例中,例如文件操作,必须确定应用程序在哪个操作系统上执行。因此,一个工具类提供了解决底层操作系统的方法。
安装
composer require dbizapps/utilities
基本用法 国际组件Unicode(ICU)
在创建工具类的实例时,默认数据集从配置文件加载。
// create new currency class loads default configuration
$currencies = new Currency();
$locales = new Locale();
$timezones = new Timezone();
数据集可以通过键值对进行搜索
// search for datasets
$currencies->search('code', 'USD']);
$locales->search('code', 'de']);
自定义用法 国际组件Unicode(ICU)
可以通过构造方法加载自定义工具数据集。自定义数据集必须符合内部数据结构
// create new currency class with custom dataset
$currencies = new Currency([...]);
$locales = new Locale([...]);
$timezones = new Timezone([...]);
操作系统用法
// static method to retrieve underlying os
$os = OperatingSystem::getOs()
// static method to evaluate if operating system is windows
$check = OperatingSystem::isWindows()
// static method to evaluate if operating system is windows
$check = OperatingSystem::isMac()