@@ -77,7 +77,7 @@ Things you can do with your Ruler
77
77
``` php
78
78
<?php
79
79
80
- // These are variables . They'll be replaced by terminal values during Rule evaluation.
80
+ // These are Variables . They'll be replaced by terminal values during Rule evaluation.
81
81
82
82
$a = $rb['a'];
83
83
$b = $rb['b'];
@@ -98,18 +98,18 @@ $a->notEqualTo($b); // true if $a != $b
98
98
``` php
99
99
<?php
100
100
101
- // Create a rule with an $a == $b condition
101
+ // Create a Rule with an $a == $b condition
102
102
$aEqualsB = $rb->create($a->equalTo($b));
103
103
104
- // Create another rule with an $a != $b condition
104
+ // Create another Rule with an $a != $b condition
105
105
$aDoesNotEqualB = $rb->create($a->notEqualTo($b));
106
106
107
107
// Now combine them for a tautology!
108
108
// (Because Rules are also Propositions, they can be combined to make MEGARULES)
109
109
$eitherOne = $rb->create($rb->logicalOr($aEqualsB, $aDoesNotEqualB));
110
110
111
111
// Just to mix things up, we'll populate our evaluation context with completely
112
- // random variables ...
112
+ // random values ...
113
113
$context = new Context(array(
114
114
'a' => rand(),
115
115
'b' => rand(),
@@ -187,27 +187,27 @@ $hiEveryoneElse = $rb->create(
187
187
188
188
$rules = new RuleSet(array($hiJustin, $hiJon, $hiEveryoneElse));
189
189
190
- // Let's add one more rule , so non-authenticated users have a chance to log in
190
+ // Let's add one more Rule , so non-authenticated users have a chance to log in
191
191
$redirectForAuthentication = $rb->create($rb->logicalNot($userIsLoggedIn), function() {
192
192
header('Location: /login');
193
193
exit;
194
194
});
195
195
196
196
$rules->addRule($redirectForAuthentication);
197
197
198
- // Now execute() all true rules .
198
+ // Now execute() all true Rules .
199
199
//
200
- // In this case, all of our rules are mutually exclusive so at most one of them will execute...
200
+ // In this case, all of our Rules are mutually exclusive so at most one of them will execute...
201
201
$rules->executeRules($context);
202
202
```
203
203
204
204
205
205
Dynamically populate your evaluation Context
206
206
--------------------------------------------
207
207
208
- Several of our examples above use static values for the context variables . While
208
+ Several of our examples above use static values for the context Variables . While
209
209
that's good for examples, it's not as useful in the Real World. You'll probably
210
- want to evaluate rules based on all sorts of things...
210
+ want to evaluate Rules based on all sorts of things...
211
211
212
212
You can think of the Context as a ViewModel for Rule evaluation. You provide the
213
213
static values, or even code for lazily evaluating the Variables needed by your
@@ -242,7 +242,7 @@ $context['orderCount'] = function() use ($em, $context) {
242
242
};
243
243
```
244
244
245
- Now you have all the information you need to make rules based on Order count or
245
+ Now you have all the information you need to make Rules based on Order count or
246
246
the current User, or any number of other crazy things. I dunno, maybe this is
247
247
for a shipping price calculator?
248
248
0 commit comments