dwo / comparator
:TODO:
Installs: 6 394
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Requires
- php: >=5.3.0
Requires (Dev)
- phpunit/phpunit: ~4
This package is not auto-updated.
Last update: 2024-11-06 17:02:49 UTC
README
Comparator
The Comparator is a little library to compare values in a easy way. Very useful for dynamic comparisons.
$operator = '=='; $argument1 = 1; $argument2 = 1; if(Comparator::compare($operator, $argument1, $argument2)) { //do something }
Operators
The Comparator comes with some operators:
- '==', '!=', '>', '>=', '<', '<='
- 'version'
- 'substr'
- 'bit'
- 'between'
- 'bool'
- 'day'
- 'date_range'
//Example 'bool' operator if(Comparator::compare('bool', true, $_GET['activated'])) { //do something } //Example 'date' operator if(Comparator::compare('day', 'now', $date)) { //do something } //Example 'date_range' operator if(Comparator::compare('date_range', new \DateTime(), $dateFrom, $dateTo)) { //do something }
The 'date' and 'date_range' operators can handle Timestamps, DateTimeObjects as well as DateStrings ('now' or '-2 days').
Installation
Installation with Composer
composer.phar require dwo/comparator