PluginProbe
Media Cloud Sync / 1.4.1
Media Cloud Sync v1.4.1
1.4.1 1.4.0 1.3.12 1.3.11 1.3.10 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.1.0 1.1.1 1.2.0 1.2.10 1.2.11 1.2.12 1.2.13 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.2.7 1.2.8 1.2.9 All 35 releases
media-cloud-sync / includes / sdk / s3 / Aws / EndpointV2 / Rule / TreeRule.php

TreeRule.php in Media Cloud Sync 1.4.1, at includes/sdk/s3/Aws/EndpointV2/Rule/TreeRule.php

53 lines 1.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Dudlewebs\WPMCS\s3\Aws\EndpointV2\Rule;
4
5 use Dudlewebs\WPMCS\s3\Aws\EndpointV2\Ruleset\RulesetStandardLibrary;
6 class TreeRule extends AbstractRule
7 {
8 /** @var array */
9 private $rules;
10 public function __construct(array $definition)
11 {
12 parent::__construct($definition);
13 $this->rules = $this->createRules($definition['rules']);
14 }
15 /**
16 * @return array
17 */
18 public function getRules()
19 {
20 return $this->rules;
21 }
22 /**
23 * If a tree rule's conditions evaluate successfully, iterate over its
24 * subordinate rules and return a result if there is one. If any of the
25 * subsequent rules are trees, the function will recurse until it reaches
26 * an error or an endpoint rule
27 *
28 * @return mixed
29 */
30 public function evaluate(array $inputParameters, RulesetStandardLibrary $standardLibrary)
31 {
32 if ($this->evaluateConditions($inputParameters, $standardLibrary)) {
33 foreach ($this->rules as $rule) {
34 $inputParametersCopy = $inputParameters;
35 $evaluation = $rule->evaluate($inputParametersCopy, $standardLibrary);
36 if ($evaluation !== \false) {
37 return $evaluation;
38 }
39 }
40 }
41 return \false;
42 }
43 private function createRules(array $rules)
44 {
45 $rulesList = [];
46 foreach ($rules as $rule) {
47 $ruleType = RuleCreator::create($rule['type'], $rule);
48 $rulesList[] = $ruleType;
49 }
50 return $rulesList;
51 }
52 }
53