PluginProbe
WooCommerce / 11.1.0
WooCommerce v11.1.0
11.1.0 11.1.0-rc.2 11.1.0-rc.1 11.1.0-beta.2 11.1.0-beta.1 11.0.1 11.0.0 11.0.0-rc.3 11.0.0-rc.2 11.0.0-rc.1 11.0.0-beta.2 11.0.0-beta.1 10.9.4 10.9.3 10.9.2 10.9.1 10.9.0 10.9.0-rc.1 10.9.0-beta.2 10.9.0-beta.1 10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 All 648 releases
woocommerce / src / Admin / RemoteSpecs / RuleProcessors / BaseLocationStateRuleProcessor.php
BaseLocationStateRuleProcessor.php
56 lines 1.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Rule processor that performs a comparison operation against the base
4 * location - state.
5 */
6
7 namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors;
8
9 defined( 'ABSPATH' ) || exit;
10
11 /**
12 * Rule processor that performs a comparison operation against the base
13 * location - state.
14 */
15 class BaseLocationStateRuleProcessor implements RuleProcessorInterface {
16 /**
17 * Performs a comparison operation against the base location - state.
18 *
19 * @param object $rule The specific rule being processed by this rule processor.
20 * @param object $stored_state Stored state.
21 *
22 * @return bool The result of the operation.
23 */
24 public function process( $rule, $stored_state ) {
25 $base_location = wc_get_base_location();
26 if ( ! is_array( $base_location ) || ! array_key_exists( 'state', $base_location ) ) {
27 return false;
28 }
29
30 return ComparisonOperation::compare(
31 $base_location['state'],
32 $rule->value,
33 $rule->operation
34 );
35 }
36
37 /**
38 * Validates the rule.
39 *
40 * @param object $rule The rule to validate.
41 *
42 * @return bool Pass/fail.
43 */
44 public function validate( $rule ) {
45 if ( ! isset( $rule->value ) ) {
46 return false;
47 }
48
49 if ( ! isset( $rule->operation ) ) {
50 return false;
51 }
52
53 return true;
54 }
55 }
56