Comparison.php
841 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?php
namespace ACP\Search\Helper\TaxQuery;
use ACP\Search\Value;
class Comparison {
/**
* @var string
*/
protected $taxonomy;
/**
* @var string
*/
protected $operator;
/**
* @var string
*/
private $field;
/**
* @var Value
*/
private $terms;
/**
* @param string $taxonomy
* @param string $operator
* @param Value $terms
* @param string $field
*/
public function __construct( $taxonomy, $operator, Value $terms, $field = 'term_id' ) {
$this->taxonomy = $taxonomy;
$this->operator = $operator;
$this->terms = $terms;
$this->field = $field;
}
/**
* @return array
*/
public function get_expression() {
$args = [
'taxonomy' => $this->taxonomy,
'terms' => $this->terms->get_value(),
'operator' => $this->operator,
'field' => $this->field,
];
return $args;
}
}