Traits
1 month ago
Either.php
1 month ago
Fns.php
1 month ago
Invoker.php
1 month ago
Logic.php
1 month ago
Obj.php
1 month ago
Relation.php
1 month ago
Str.php
1 month ago
Undefined.php
1 month ago
functions.php
1 month ago
Relation.php
44 lines
| 1 | <?php |
| 2 | |
| 3 | namespace OTGS\Installer\FP; |
| 4 | |
| 5 | use OTGS\Installer\Collect\Support\Macroable; |
| 6 | |
| 7 | class Relation { |
| 8 | |
| 9 | use Macroable; |
| 10 | |
| 11 | public static function init() { |
| 12 | |
| 13 | self::macro( 'equals', curryN( 2, function ( $a, $b ) { |
| 14 | return $a === $b; |
| 15 | } ) ); |
| 16 | |
| 17 | self::macro( 'lt', curryN( 2, function ( $a, $b ) { |
| 18 | if ( is_string( $a ) && is_string( $b ) ) { |
| 19 | return strcmp( $a, $b ) < 0; |
| 20 | } |
| 21 | |
| 22 | return $a < $b; |
| 23 | } ) ); |
| 24 | |
| 25 | self::macro( 'gt', curryN( 2, function ( $a, $b ) { |
| 26 | return self::lt( $b, $a ); |
| 27 | } ) ); |
| 28 | |
| 29 | self::macro( 'lte', curryN( 2, function ( $a, $b ) { |
| 30 | return ! self::gt( $a, $b ); |
| 31 | } ) ); |
| 32 | |
| 33 | self::macro( 'gte', curryN( 2, function ( $a, $b ) { |
| 34 | return ! self::lt( $a, $b ); |
| 35 | } ) ); |
| 36 | |
| 37 | self::macro( 'propEq', curryN( 3, function ( $prop, $value, $obj ) { |
| 38 | return Obj::prop( $prop, $obj ) === $value; |
| 39 | } ) ); |
| 40 | |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | Relation::init(); |