| 1 |
<?php |
| 2 |
|
| 3 |
namespace Aws\EndpointV2\Rule; |
| 4 |
|
| 5 |
use Aws\EndpointV2\Ruleset\RulesetStandardLibrary; |
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
abstract class AbstractRule |
| 12 |
{ |
| 13 |
private $conditions; |
| 14 |
private $documentation; |
| 15 |
|
| 16 |
public function __construct(array $definition) |
| 17 |
{ |
| 18 |
$this->conditions = $definition['conditions']; |
| 19 |
$this->documentation = isset($definition['documentation']) ? |
| 20 |
$definition['documentation'] : null; |
| 21 |
} |
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
public function getConditions() |
| 27 |
{ |
| 28 |
return $this->conditions; |
| 29 |
} |
| 30 |
|
| 31 |
|
| 32 |
|
| 33 |
|
| 34 |
public function getDocumentation() |
| 35 |
{ |
| 36 |
return $this->documentation; |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
protected function evaluateConditions( |
| 45 |
array &$inputParameters, |
| 46 |
RulesetStandardLibrary $standardLibrary |
| 47 |
) |
| 48 |
{ |
| 49 |
foreach($this->getConditions() as $condition) { |
| 50 |
$result = $standardLibrary->callFunction($condition, $inputParameters); |
| 51 |
if (is_null($result) || $result === false) { |
| 52 |
return false; |
| 53 |
} |
| 54 |
} |
| 55 |
return true; |
| 56 |
} |
| 57 |
|
| 58 |
abstract public function evaluate( |
| 59 |
array $inputParameters, |
| 60 |
RulesetStandardLibrary $standardLibrary |
| 61 |
); |
| 62 |
} |