PluginProbe
Depicter — Popup & Slider Builder / trunk
Depicter — Popup & Slider Builder vtrunk
4.8.1 trunk 1.0.0 1.1.0 1.1.2 1.1.4 1.1.6 1.1.7 1.1.8 1.1.9 1.2.0 1.3.0 1.3.1 1.3.2 1.3.3 1.3.5 1.3.8 1.5.0 1.5.1 1.5.2 1.5.5 1.6.0 1.6.1 1.6.2 1.7.0 All 76 releases
depicter / app / src / Rules / DisplayCondition / DisplayConditionGroup.php

DisplayConditionGroup.php in Depicter — Popup & Slider Builder trunk, at app/src/Rules/DisplayCondition/DisplayConditionGroup.php

71 lines 1.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 namespace Depicter\Rules\DisplayCondition;
3
4 class DisplayConditionGroup {
5
6 /**
7 * @var string
8 */
9 public $matchingMode = 'all';
10
11 /**
12 * @var int
13 */
14 public $order = 0;
15
16 /**
17 * @var string
18 */
19 public $operator = 'or';
20
21 /**
22 * Condition instances in this group
23 *
24 * @var \Depicter\Rules\Condition\Base[]
25 */
26 public $conditions;
27
28 /**
29 * Condition instances in this group
30 *
31 * @return \Depicter\Rules\Condition\Base[]
32 */
33 public function conditions(){
34 return $this->conditions;
35 }
36
37 /**
38 * Check if conditions are passed in current matchingMode
39 *
40 * @param $value
41 *
42 * @return bool
43 */
44 public function check( $value = null ){
45
46 if( ! empty( $this->conditions ) ){
47
48 if( $this->matchingMode === 'any' ){
49 foreach( $this->conditions as $condition ){
50 if( $condition->check( $value ) ){
51 return true;
52 }
53 }
54 return false;
55
56 // if matchingMode is set to 'all'
57 } else {
58 foreach( $this->conditions as $condition ){
59 if( ! $condition->check( $value ) ){
60 return false;
61 }
62 }
63
64 return true;
65 }
66 }
67
68 return true;
69 }
70 }
71