function apply($input_data, $fields) { /* Applies the operators defined in the predicate as strings toi the provided input data */ // for missing operators if (!array_key_exists($this->field, $input_data)) { // text and item fields will treat missing values by following the // doesn't contain branch if (is_null($this->term)) { return $this->missing || $this->operator == '=' && is_null($this->value); } } else { if ($this->operator == "!=" && is_null($this->value)) { return true; } } $op = operatorFunction($this->operator); if ($this->term != null) { if ($fields->{$this->field}->optype == 'text') { $term_forms = property_exists($fields->{$this->field}->summary, 'term_forms') && !empty($fields->{$this->field}->summary->term_forms) ? property_exists($fields->{$this->field}->summary->term_forms, $this->term) ? $fields->{$this->field}->summary->term_forms->{$this->term} : array() : array(); $terms = array($this->term); $terms = array_merge($terms, $term_forms); $options = $fields->{$this->field}->term_analysis; return $op(term_matches(array_key_exists($this->field, $input_data) ? $input_data[$this->field] : "", $terms, $options), $this->value); } else { $options = $fields->{$this->field}->item_analysis; return $op(item_matches(array_key_exists($this->field, $input_data) ? $input_data[$this->field] : "", $this->term, $options), $this->value); } } if ($this->operator == "in") { return $op($this->value, $input_data[$this->field]); } else { return $op($input_data[$this->field], $this->value); } }
function apply($input_data, $fields) { /* Applies the operators defined in the predicate as strings toi the provided input data */ // for missing operators if (!array_key_exists($this->field, $input_data)) { return $this->missing || $this->operator == '=' && is_null($this->value); } else { if ($this->operator == "!=" && is_null($this->value)) { return true; } } $op = operatorFunction($this->operator); if ($this->term != null) { $term_forms = property_exists($fields->{$this->field}->summary, 'term_forms') && !empty($fields->{$this->field}->summary->term_forms) ? property_exists($fields->{$this->field}->summary->term_forms, $this->term) ? $fields->{$this->field}->summary->term_forms->{$this->term} : array() : array(); $terms = array($this->term); $terms = array_merge($terms, $term_forms); $options = $fields->{$this->field}->term_analysis; return $op($this->term_matches($input_data[$this->field], $terms, $options), $this->value); } if ($this->operator == "in") { return $op($this->value, $input_data[$this->field]); } else { return $op($input_data[$this->field], $this->value); } }