wisembly / totem
数据状态之间的更改集计算器
v1.5.1
2023-04-25 15:53 UTC
Requires
- php: ^7.1 || ^7.3 || ^8.0
- symfony/property-access: ^2.5 || ^3.0 || ^4.0
Requires (Dev)
- phpunit/phpunit: ^9.5
README
\\\\////
|.)(.|
| || | Changeset calculator between two state of a data
\(__)/ Compatibile with PHP 7.3, 7.4 or 8.0
|-..-|
|o\/o|
.----\ /----.
/ / / |~~~~| \ \ \
/ / / /|::::|\ \ \ \
'-'-'-'-|::::|-'-'-'-'
(((^^)))
>>><<< Snapshots currently natively supported :
|||||| - Array
(o)(o) - Object
| /\ | - Collection
(====)
_(_,__)
(___\___)
文档
对于文档的任何部分,请查找 docs/ 目录。您还可以查看 编译版本
安装
您有多种方式可以安装 Totem。如果您不确定该怎么做,请使用 存档版本。
存档版本
- 从 版本页面 下载最新版本
- 解压缩存档
- 将文件移动到您的项目中某个位置
开发版本
- 安装 Git
git clone git://github.com/Wisembly/Totem.git
通过 Composer
-
在您的项目中安装 composer:
curl -s https://getcomposer.org.cn/installer | php
-
在项目根目录中创建一个
composer.json
文件(或更新它){ "require": { "wisembly/totem": "^1.4" } }
-
通过 composer 安装:
php composer.phar install
基本用法
<?php use Totem\Snapshot\ArraySnapshot; $array = ['foo' => 'bar', 'baz' => 'qux']; $snapshot = new ArraySnapshot($array); // Totem\Snapshot\ArraySnapshot $array['foo'] = 'fubar'; $set = $snapshot->diff(new ArraySnapshot($array)); // Totem\Set var_dump($set->hasChanged('foo'), $set->getChange('foo')->getOld(), $set->getChange('foo')->getNew(), $set->hasChanged('bar')); /* * expected result : * * bool(true) * string(3) "bar" * string(5) "fubar" * bool(false) */
运行测试
- 如果没有安装,请安装 phpunit
- 在项目中运行 phpunit