blob: 94da12d01b43de9e41d6b5ba0af646a70e781510 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
<?php
namespace Aws\EndpointV2\Rule;
use Aws\EndpointV2\Ruleset\RulesetStandardLibrary;
/**
* A rule within a rule set. All rules contain a conditions property,
* which can be empty, and documentation about the rule.
*/
abstract Class AbstractRule
{
private $conditions;
private $documentation;
public function __construct(array $definition)
{
$this->conditions = $definition['conditions'];
$this->documentation = isset($definition['documentation']) ?
$definition['documentation'] : null;
}
/**
* @return array
*/
public function getConditions()
{
return $this->conditions;
}
/**
* @return mixed
*/
public function getDocumentation()
{
return $this->documentation;
}
/**
* Determines if all conditions for a given rule are met.
*
* @return boolean
*/
protected function evaluateConditions(
array &$inputParameters,
RulesetStandardLibrary $standardLibrary
)
{
foreach($this->getConditions() as $condition) {
$result = $standardLibrary->callFunction($condition, $inputParameters);
if (is_null($result) || $result === false) {
return false;
}
}
return true;
}
abstract public function evaluate(
array $inputParameters,
RulesetStandardLibrary $standardLibrary
);
}
|