Transformers
1 year ago
BaseLocationCountryRuleProcessor.php
2 years ago
BaseLocationStateRuleProcessor.php
2 years ago
ComparisonOperation.php
2 years ago
ContextPluginsRuleProcessor.php
1 year ago
EvaluateAndGetStatus.php
2 years ago
EvaluateOverrides.php
1 year ago
EvaluationLogger.php
1 year ago
FailRuleProcessor.php
2 years ago
GetRuleProcessor.php
2 years ago
GetRuleProcessorForContext.php
1 year ago
IsEcommerceRuleProcessor.php
2 years ago
IsWooExpressRuleProcessor.php
2 years ago
NotRuleProcessor.php
2 years ago
NoteStatusRuleProcessor.php
2 years ago
OnboardingProfileRuleProcessor.php
2 years ago
OptionRuleProcessor.php
2 years ago
OrRuleProcessor.php
2 years ago
OrderCountRuleProcessor.php
2 years ago
OrdersProvider.php
2 years ago
PassRuleProcessor.php
2 years ago
PluginVersionRuleProcessor.php
2 years ago
PluginsActivatedRuleProcessor.php
2 years ago
ProductCountRuleProcessor.php
1 year ago
PublishAfterTimeRuleProcessor.php
2 years ago
PublishBeforeTimeRuleProcessor.php
2 years ago
RuleEvaluator.php
1 year ago
RuleProcessorInterface.php
2 years ago
StoredStateRuleProcessor.php
2 years ago
StoredStateSetupForProducts.php
2 years ago
TotalPaymentsVolumeProcessor.php
1 year ago
WCAdminActiveForProvider.php
2 years ago
WCAdminActiveForRuleProcessor.php
2 years ago
WooCommerceAdminUpdatedRuleProcessor.php
2 years ago
NotRuleProcessor.php
65 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Rule processor that negates the rules in the rule's operand. |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Admin\RemoteSpecs\RuleProcessors; |
| 7 | |
| 8 | defined( 'ABSPATH' ) || exit; |
| 9 | |
| 10 | /** |
| 11 | * Rule processor that negates the rules in the rule's operand. |
| 12 | */ |
| 13 | class NotRuleProcessor implements RuleProcessorInterface { |
| 14 | |
| 15 | /** |
| 16 | * The rule evaluator to use. |
| 17 | * |
| 18 | * @var RuleEvaluator |
| 19 | */ |
| 20 | protected $rule_evaluator; |
| 21 | |
| 22 | /** |
| 23 | * Constructor. |
| 24 | * |
| 25 | * @param RuleEvaluator $rule_evaluator The rule evaluator to use. |
| 26 | */ |
| 27 | public function __construct( $rule_evaluator = null ) { |
| 28 | $this->rule_evaluator = null === $rule_evaluator |
| 29 | ? new RuleEvaluator() |
| 30 | : $rule_evaluator; |
| 31 | } |
| 32 | |
| 33 | /** |
| 34 | * Evaluates the rules in the operand and negates the result. |
| 35 | * |
| 36 | * @param object $rule The specific rule being processed by this rule processor. |
| 37 | * @param object $stored_state Stored state. |
| 38 | * |
| 39 | * @return bool The result of the operation. |
| 40 | */ |
| 41 | public function process( $rule, $stored_state ) { |
| 42 | $evaluated_operand = $this->rule_evaluator->evaluate( |
| 43 | $rule->operand, |
| 44 | $stored_state |
| 45 | ); |
| 46 | |
| 47 | return ! $evaluated_operand; |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Validates the rule. |
| 52 | * |
| 53 | * @param object $rule The rule to validate. |
| 54 | * |
| 55 | * @return bool Pass/fail. |
| 56 | */ |
| 57 | public function validate( $rule ) { |
| 58 | if ( ! isset( $rule->operand ) ) { |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | return true; |
| 63 | } |
| 64 | } |
| 65 |