amsify42/php-vars-data
Composer 安装命令:
composer require amsify42/php-vars-data
包简介
This is a php package to deal with different data type variables
README 文档
README
This is a php package to deal with different data type variables.
Installation
$ composer require amsify42/php-vars-data
Table of Contents
1. Evaluate
This is a simple class Amsify42\PHPVarsData\Data\Evaluate which converts string to its actual evaluated value and convert actual value to its evaluated string.
use Amsify42\PHPVarsData\Data\Evaluate;
To convert string to actual evaluated value
Evaluate::toValue('true'); Evaluate::toValue('false'); Evaluate::toValue('null'); Evaluate::toValue('42'); Evaluate::toValue('4.2'); Evaluate::toValue('Amsify');
To convert actual value to its evaluated string
Evaluate::toString(true); Evaluate::toString(false); Evaluate::toString(null); Evaluate::toString(42); Evaluate::toString(4.2);
To convert short count string value to its evaluated count
Evaluate::toCount('2.5K'); Evaluate::toCount('4.2M'); Evaluate::toCount('1.1B');
We can do the same with helper methods as well
evaluate_to_value('true'); evaluate_to_string(true); evaluate_to_count('3.1k');
2. Array Simple
Its a helper class to set/get any level array element easily.
use Amsify42\PHPVarsData\Data\ArraySimple;
This is how we can initialize array
$arraySimple = new ArraySimple([1,2,3]);
or
$arraySimple = new get_array_simple([1,2,3]);
With the initialized array, we can do all the things which we do with conventional array like setting/unsetting keys, iterating.
foreach($arraySimple as $item) { echo $item; } $item[] = 4; unset($item[4]);
Apart from doing the above, we can also set/get element value from any level like this
$arraySimple = get_array_simple([ 'name' => 'amsify', 'detail' => [ 'location' => 'somewhere', 'more_detail' => [ 'do' => 'something', 'ids' => [42] ] ] ]); echo $arraySimple->get('detail.location'); $arraySimple->set('detail.more_detail.do', 'nothing'); echo $arraySimple->get('detail.more_detail.do');
If you have noticed, we are passing key levels separated by dot.
Note: Make sure the element key names in array does not contain dots else results might not be as expected.
amsify42/php-vars-data 适用场景与选型建议
amsify42/php-vars-data 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.94k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 amsify42/php-vars-data 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 amsify42/php-vars-data 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 1.94k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 6
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-03-21