PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.17.0
GiveWP – Donation Plugin and Fundraising Platform v4.17.0
4.17.0 4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 All 256 releases
give / vendor / vendor-prefixed / stellarwp / field-conditions / src / NestedCondition.php

NestedCondition.php in GiveWP – Donation Plugin and Fundraising Platform 4.17.0, at vendor/vendor-prefixed/stellarwp/field-conditions/src/NestedCondition.php

63 lines 1.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Vendors\StellarWP\FieldConditions;
4
5 use ArrayIterator;
6 use Give\Vendors\StellarWP\FieldConditions\Concerns\HasConditions;
7 use Give\Vendors\StellarWP\FieldConditions\Concerns\HasLogicalOperator;
8 use Give\Vendors\StellarWP\FieldConditions\Contracts\Condition;
9 use Give\Vendors\StellarWP\FieldConditions\Contracts\ConditionSet;
10
11 /**
12 * A condition that holds and evaluates multiple conditions.
13 *
14 * @since 1.1.1 implement the ConditionSet interface
15 * @since 1.0.0
16 *
17 * @uses HasConditions<Condition>
18 */
19 class NestedCondition implements Condition, ConditionSet
20 {
21 use HasLogicalOperator;
22 use HasConditions;
23
24 /**
25 * The type of condition.
26 */
27 const TYPE = 'nested';
28
29 /**
30 * @since 1.0.0
31 *
32 * @param Condition[] $conditions
33 * @param 'and'|'or' $logicalOperator
34 */
35 public function __construct(array $conditions = [], string $logicalOperator = 'and')
36 {
37 $this->conditions = $conditions;
38 $this->setLogicalOperator($logicalOperator);
39 }
40
41 /**
42 * @inheritDoc
43 *
44 * @since 1.0.0
45 */
46 public function jsonSerialize(): array
47 {
48 return [
49 'type' => static::TYPE,
50 'conditions' => $this->conditions,
51 'boolean' => $this->logicalOperator,
52 ];
53 }
54
55 /**
56 * @since 1.1.1
57 */
58 public function getIterator(): ArrayIterator
59 {
60 return new ArrayIterator($this->conditions);
61 }
62 }
63