| Server IP : 43.130.17.34 / Your IP : 216.73.217.6 Web Server : nginx/1.28.0 System : Linux VM-4-12-opencloudos 6.6.92-34.1.oc9.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Jun 25 21:32:13 CST 2025 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,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,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wwwroot/yespkg.com/wp-content/plugins/admin-columns-pro.5.1.3/classes/Search/ |
Upload File : |
<?php
namespace ACP\Search;
use ACP\Search\Query\Bindings;
use LogicException;
abstract class Comparison {
/**
* @var Labels
*/
protected $labels;
/**
* @var Operators
*/
protected $operators;
/**
* @var string
*/
protected $value_type;
/**
* @param Operators $operators
* @param string $value_type
* @param Labels|null $labels
*/
public function __construct( Operators $operators, $value_type = null, Labels $labels = null ) {
if ( null === $labels ) {
$labels = new Labels();
}
if ( null === $value_type ) {
$value_type = Value::STRING;
}
$this->labels = $labels;
$this->value_type = $value_type;
$this->operators = $operators;
$this->validate_value_type();
}
private function validate_value_type() {
$value_types = [
Value::DATE,
Value::INT,
Value::DECIMAL,
Value::STRING,
];
if ( ! in_array( $this->value_type, $value_types ) ) {
throw new LogicException( 'Unsupported value type found.' );
}
}
/**
* @return Operators
*/
public function get_operators() {
return $this->operators;
}
/**
* @return string
*/
public function get_value_type() {
return $this->value_type;
}
/**
* @return array
*/
public function get_labels() {
$labels = [];
foreach ( $this->get_operators() as $operator ) {
$labels[ $operator ] = $this->labels->get_offset( $operator );
}
return $labels;
}
/**
* @param string $operator
* @param Value $value
*
* @return Bindings
*/
final public function get_query_bindings( $operator, Value $value ) {
if ( $this->operators->search( $operator ) === false ) {
throw new LogicException( 'Unsupported operator found.' );
}
if ( $this->value_type !== $value->get_type() ) {
throw new LogicException( 'Value types are not identical.' );
}
return $this->create_query_bindings( $operator, $value );
}
/**
* @param string $operator
* @param Value $value
*
* @return Bindings
*/
abstract protected function create_query_bindings( $operator, Value $value );
}