PluginProbe
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar / 3.3.3
NotificationX – FOMO, Live Sales Notification, WooCommerce Sales Popup, GDPR, Social Proof, Announcement Banner & Floating Notification Bar v3.3.3
3.3.3 3.3.2 3.3.1 3.3.0 3.2.14 3.2.13 3.2.12 3.2.11 3.2.10 3.2.9 3.2.8 3.2.7 trunk 0.2.5.5 0.2.5.6 0.2.5.7 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.1.2 1.1.3 1.1.4 All 158 releases
← All changes | includes/Core/Rule.php +57 -0 0.2.5.5 → 3.3.3 View file →
@@ -1,0 +1,57 @@
1 +<?php
2 +/**
3 + * Rule
4 + *
5 + * @package NotificationX\Core
6 + */
7 +
8 +namespace NotificationX\Core;
9 +
10 +use ArrayIterator;
11 +use ArrayObject;
12 +use JsonSerializable;
13 +use NotificationX\Admin\Settings;
14 +use Serializable;
15 +
16 +class Rule implements JsonSerializable {
17 + public $condition;
18 + public $name;
19 + public $value;
20 + public function __construct($condition, $name, $value){
21 + $this->condition = $condition;
22 + $this->name = $name;
23 + $this->value = $value;
24 + }
25 +
26 + public function add_value($value){
27 + if(!is_array($this->value)){
28 + $this->value = [$this->value];
29 + }
30 + if(is_a($value, 'NotificationX\Core\Rule')){
31 + $value = $value->value;
32 + }
33 + if(is_array($value)){
34 + $this->value = array_merge($this->value, $value);
35 + }
36 + else{
37 + $this->value[] = $value;
38 + }
39 + $this->value = array_values(array_unique($this->value));
40 + }
41 +
42 + public function can_add($rule){
43 + if($this->condition == 'includes' && $this->condition == $rule->condition && $this->name == $rule->name){
44 + return true;
45 + }
46 + return false;
47 + }
48 +
49 + #[\ReturnTypeWillChange]
50 + public function jsonSerialize(){
51 + return [
52 + $this->condition,
53 + $this->name,
54 + $this->value,
55 + ];
56 + }
57 +}