trilations / equatable
2.0.0
2022-08-19 10:20 UTC
Requires
- php: ^7.4 || ^8.0
Requires (Dev)
- phpcompatibility/php-compatibility: ^9.3
- phpro/grumphp-shim: ^1.13
- phpunit/phpunit: ^9
- squizlabs/php_codesniffer: ^3.7
This package is auto-updated.
Last update: 2024-09-19 15:22:30 UTC
README
用于管理EquatableInterface和EquatableTrait的库(composer包)。
Equatable可以指示当前对象是否与另一个对象相等。
安装
将其添加到您的composer.json
{
"repositories": [
{
"type": "vcs",
"url": "https://gitlab.com/trilations/equatable.git"
}
],
"require": {
"trilations/equatable": "^2.0"
}
}
然后运行composer update
composer update
用法
use Trilations\Equatable\Interfaces\EquatableInterface;
use Trilations\Equatable\Traits\EquatableTrait;
// Say, we have 2 objects ($a and $b) that we want to compare
// And $a implements EquatableInterface
if ($a instanceof EquatableInterface) {
$result = $a->equals($b);
return $result;
}
贡献
安装
# make sure you have php 7.4 or higher
php -v
# make sure you have composer installed
composer -v
# clone the repository
git clone git@gitlab.com:trilations/Equatable.git
# cd into the directory
cd Equatable
# install dependencies
composer install
测试
# running all tests
./vendor/bin/phpunit
# checking the code coverage (requires Xdebug)
./vendor/bin/phpunit --coverage-text
./vendor/bin/phpunit --coverage-html coverage.html # generate html report
# you might need to prefix these commands with XDEBUG_MODE=coverage
XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-text
此外,您应该定期检查与支持的PHP版本的任何不兼容性
# Runs the sniffer script as defined in composer.json
composer sniffer:php7.4
composer sniffer:php8.0
composer sniffer:php8.1