auto-patch 638-dev-dev01-2024-05-14T20_44_36
This commit is contained in:
@@ -8,66 +8,26 @@ namespace Automattic\WooCommerce\Admin\RemoteInboxNotifications;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use Automattic\WooCommerce\Admin\DeprecatedClassFacade;
|
||||
|
||||
/**
|
||||
* Rule processor that performs an OR operation on the rule's left and right
|
||||
* operands.
|
||||
*
|
||||
* @deprecated 8.8.0
|
||||
*/
|
||||
class OrRuleProcessor implements RuleProcessorInterface {
|
||||
class OrRuleProcessor extends DeprecatedClassFacade {
|
||||
/**
|
||||
* The name of the non-deprecated class that this facade covers.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors\OrRuleProcessor';
|
||||
|
||||
/**
|
||||
* Rule evaluator to use.
|
||||
* The version that this class was deprecated in.
|
||||
*
|
||||
* @var RuleEvaluator
|
||||
* @var string
|
||||
*/
|
||||
private $rule_evaluator;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param RuleEvaluator $rule_evaluator The rule evaluator to use.
|
||||
*/
|
||||
public function __construct( $rule_evaluator = null ) {
|
||||
$this->rule_evaluator = null === $rule_evaluator
|
||||
? new RuleEvaluator()
|
||||
: $rule_evaluator;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs an OR operation on the rule's left and right operands.
|
||||
*
|
||||
* @param object $rule The specific rule being processed by this rule processor.
|
||||
* @param object $stored_state Stored state.
|
||||
*
|
||||
* @return bool The result of the operation.
|
||||
*/
|
||||
public function process( $rule, $stored_state ) {
|
||||
foreach ( $rule->operands as $operand ) {
|
||||
$evaluated_operand = $this->rule_evaluator->evaluate(
|
||||
$operand,
|
||||
$stored_state
|
||||
);
|
||||
|
||||
if ( $evaluated_operand ) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Validates the rule.
|
||||
*
|
||||
* @param object $rule The rule to validate.
|
||||
*
|
||||
* @return bool Pass/fail.
|
||||
*/
|
||||
public function validate( $rule ) {
|
||||
if ( ! isset( $rule->operands ) || ! is_array( $rule->operands ) ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
protected static $deprecated_in_version = '8.8.0';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user