Set.php
1.39 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?php
/**
* Rule engine set model.
*
* @package ContentControl
* @subpackage Models
*/
namespace ContentControl\Models\RuleEngine;
/**
* Handler for condition sets.
*
* @package ContentControl
*/
class Set {
/**
* Set id.
*
* @var string
*/
public $id;
/**
* Set label.
*
* @var string
*/
public $label;
/**
* Set query.
*
* @var Query
*/
public $query;
/**
* Build a set.
*
* @param array{id:string,label:string,query:array<mixed>} $set Set data.
*/
public function __construct( $set ) {
$set = wp_parse_args( $set, [
'id' => '',
'label' => '',
'query' => [],
]);
$this->id = $set['id'];
$this->label = $set['label'];
$this->query = new Query( $set['query'] );
}
/**
* Check if this set has JS based rules.
*
* @return bool
*/
public function has_js_rules() {
return $this->query->has_js_rules();
}
/**
* Check this sets rules.
*
* @return bool
*/
public function check_rules() {
return $this->query->check_rules();
}
/**
* Get the check array for further post processing.
*
* @return array<bool|null|array<bool|null>>
*/
public function get_checks() {
return $this->query->get_checks();
}
/**
* Return the checks as an array of information.
*
* Useful for debugging.
*
* @return array<string,mixed>
*/
public function get_check_info() {
return $this->query->get_check_info();
}
}