Compare versions with logic opertation. (Actually, it's a project to test ci/cd)
- With composer
{
...
"require": {
"codecounter/versionmatcher": "0.1.0"
}
}
- Without composer
require "/path/to/VersionMatcher/autoload.php"
- Compare 2 version strings
// produce `false`
\CodeCounter\VersionMatcher::test('ver >= 1.2.0', array(
'ver' => '1.1.0'
));
- Compare with logic
// produce `true`
\CodeCounter\VersionMatcher::test('ver >= 1.2.0 && ver < 1.6.0', array(
'ver' => '1.3.0'
));
- Persisted object
$matcher = new \CodeCounter\VersionMatcher(array(
'android' => '1.3.0',
'ios' => ''
));
// produce `true`
$matcher->match('ios >= 1.4.0 || android >= 1.3.0');
// produce `false`
$matcher->match('ios >= 1.4.0 || android < 1.2.0');
For detailed usage, please view tests
directory.
- Clone repository
cd dev
cp docker-compose.example.yml docker-compose.yml
, modify it if necessarydocker-compose up -d
docker-compose exec php bash
, ssh to the containercd /var/www
then, you can run unit test by phpunit
, or code sniffer by phpcs
.
php tests/coverage-check.php
after phpunit
, this script can exit stdout with 1
when coverage < 90%, for ci notification.
This library is under MIT license.