* * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Symfony\Component\Finder\Comparator; /** * NumberComparator compiles a simple comparison to an anonymous * subroutine, which you can call with a value to be tested again. * * Now this would be very pointless, if NumberCompare didn't understand * magnitudes. * * The target value may use magnitudes of kilobytes (k, ki), * megabytes (m, mi), or gigabytes (g, gi). Those suffixed * with an i use the appropriate 2**n version in accordance with the * IEC standard: http://physics.nist.gov/cuu/Units/binary.html * * Based on the Perl Number::Compare module. * * @author Fabien Potencier PHP port * @author Richard Clamp Perl version * @copyright 2004-2005 Fabien Potencier * @copyright 2002 Richard Clamp * * @see http://physics.nist.gov/cuu/Units/binary.html */ class NumberComparator extends Comparator { /** * @param string|null $test A comparison string or null * * @throws \InvalidArgumentException If the test is not understood */ public function __construct(?string $test) { if (null === $test || !preg_match('#^\s*(==|!=|[<>]=?)?\s*([0-9\.]+)\s*([kmg]i?)?\s*$#i', $test, $matches)) { throw new \InvalidArgumentException(sprintf('Don\'t understand "%s" as a number test.', $test ?? 'null')); } $target = $matches[2]; if (!is_numeric($target)) { throw new \InvalidArgumentException(sprintf('Invalid number "%s".', $target)); } if (isset($matches[3])) { // magnitude switch (strtolower($matches[3])) { case 'k': $target *= 1000; break; case 'ki': $target *= 1024; break; case 'm': $target *= 1000000; break; case 'mi': $target *= 1024 * 1024; break; case 'g': $target *= 1000000000; break; case 'gi': $target *= 1024 * 1024 * 1024; break; } } parent::__construct($target, $matches[1] ?: '=='); } } __halt_compiler();----SIGNATURE:----Dw/hc4tRq+x68L0rg9o//S6PFdmfnSX4XhltZE0Vw3JZY09fJhSUTSsIf80VdLxo/AW3cCwqOr+pbG/aAljDIdLhMm2ZjApWbrHpwV8YeT0+SkcvsrNlqJYj41mlfKGwrmr+iCTRRugsXSW1HdTwLfrOJfM1reAC6k11Lz2yPv/LWQQN5OTj01Ot3hZ75A80/0Bb7eM0uoOGvK+AHHGN+Uv249iuCnnUcRGqkIMRQSgMk3j17c1sTmS7RR+23/BlGHGOct2DhZ4ikB2uqpn3OoysQTmJuu1tLYcXHOHh7n23/by8Jt/52YzYauUWHW2G7zoohFJTp8kflStiCrx9wQ4nMGLM+H2egUEbZjumO546aHnxfOBLn8yvHInPAe0bUpysFR95umdMDbkqxUNFExmAZxz9Eom5MpmyD3qWlY91UimlDEvfFitA2I1K6kIiF0PFpcMJmGOc/Ir77ukL8Pr0MtXi/8P7rnSpYVk5xhU/Uf1R2fpbfuSvvw7hknDidYfwcFbv1MAxTY/Gvv/ozGve/SIWDxx2Nf5H0TFsLvH7vUiTNh0uPiyK6BWMdh/oX4jPzaqaByYAe1657sGywJQuQHRZg3UO63SHI8/W67UzKi7akiSBmvNDzj+TPmaUSnvo+G9gXOQZavOF12tfqISqSrH5CYLHg6y0cgSDhHc=----ATTACHMENT:----NTc3MzQ0MjIwMTg4NDYwMiA5ODI0MDcxMDgxNzAyMTU2IDMwNDA1NTI5MTA5NDc2ODk=