Server IP : 127.0.0.2 / Your IP : 3.148.252.90 Web Server : Apache/2.4.18 (Ubuntu) System : User : www-data ( ) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : disk_free_space,disk_total_space,diskfreespace,dl,exec,fpaththru,getmyuid,getmypid,highlight_file,ignore_user_abord,leak,listen,link,opcache_get_configuration,opcache_get_status,passthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,php_uname,phpinfo,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix,_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,pclose,popen,proc_open,proc_close,proc_get_status,proc_nice,proc_terminate,shell_exec,source,show_source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest/Number/ |
Upload File : |
<?php namespace Hamcrest\Number; /* Copyright (c) 2009 hamcrest.org */ use Hamcrest\Description; use Hamcrest\TypeSafeMatcher; class OrderingComparison extends TypeSafeMatcher { private $_value; private $_minCompare; private $_maxCompare; public function __construct($value, $minCompare, $maxCompare) { parent::__construct(self::TYPE_NUMERIC); $this->_value = $value; $this->_minCompare = $minCompare; $this->_maxCompare = $maxCompare; } protected function matchesSafely($other) { $compare = $this->_compare($this->_value, $other); return ($this->_minCompare <= $compare) && ($compare <= $this->_maxCompare); } protected function describeMismatchSafely($item, Description $mismatchDescription) { $mismatchDescription ->appendValue($item)->appendText(' was ') ->appendText($this->_comparison($this->_compare($this->_value, $item))) ->appendText(' ')->appendValue($this->_value) ; } public function describeTo(Description $description) { $description->appendText('a value ') ->appendText($this->_comparison($this->_minCompare)) ; if ($this->_minCompare != $this->_maxCompare) { $description->appendText(' or ') ->appendText($this->_comparison($this->_maxCompare)) ; } $description->appendText(' ')->appendValue($this->_value); } /** * The value is not > $value, nor < $value. * * @factory */ public static function comparesEqualTo($value) { return new self($value, 0, 0); } /** * The value is > $value. * * @factory */ public static function greaterThan($value) { return new self($value, -1, -1); } /** * The value is >= $value. * * @factory atLeast */ public static function greaterThanOrEqualTo($value) { return new self($value, -1, 0); } /** * The value is < $value. * * @factory */ public static function lessThan($value) { return new self($value, 1, 1); } /** * The value is <= $value. * * @factory atMost */ public static function lessThanOrEqualTo($value) { return new self($value, 0, 1); } // -- Private Methods private function _compare($left, $right) { $a = $left; $b = $right; if ($a < $b) { return -1; } elseif ($a == $b) { return 0; } else { return 1; } } private function _comparison($compare) { if ($compare > 0) { return 'less than'; } elseif ($compare == 0) { return 'equal to'; } else { return 'greater than'; } } }