D7net
Home
Console
Upload
information
Create File
Create Folder
About
Tools
:
/
opt
/
psa
/
admin
/
plib
/
modules
/
advisor
/
vendor
/
icecave
/
parity
/
src
/
Comparator
/
Filename :
PhpComparator.php
back
Copy
<?php namespace PleskAdvisor\Icecave\Parity\Comparator; /** * A comparator that compares using the built-in PHP less than operator. */ class PhpComparator implements Comparator { /** * Compare two values, yielding a result according to the following table: * * +--------------------+---------------+ * | Condition | Result | * +--------------------+---------------+ * | $this == $value | $result === 0 | * | $this < $value | $result < 0 | * | $this > $value | $result > 0 | * +--------------------+---------------+ * * @param mixed $lhs The first value to compare. * @param mixed $rhs The second value to compare. * * @return int The result of the comparison. */ public function compare($lhs, $rhs) : int { if ($lhs < $rhs) { return -1; } elseif ($rhs < $lhs) { return +1; } return 0; } /** * An alias for compare(). * * @param mixed $lhs The first value to compare. * @param mixed $rhs The second value to compare. * * @return int The result of the comparison. */ public function __invoke($lhs, $rhs) : int { return $this->compare($lhs, $rhs); } }