Bristol SU Support Package
LogicTesterFake.php
Go to the documentation of this file.
1 <?php
2 
4 
10 
14 class LogicTesterFake implements LogicTester
15 {
16 
22  private $results = [];
23 
30  public function forLogic(Logic $logic)
31  {
32  if (!array_key_exists($logic->id, $this->results)) {
33  $this->results[$logic->id] = new LogicTesterResult();
34  }
35  return $this->results[$logic->id];
36  }
37 
38  public function bind()
39  {
40  app()->instance(LogicTester::class, $this);
41  }
42 
43 
53  public function evaluate(Logic $logic, $userModel = null, $groupModel = null, $roleModel = null): bool
54  {
55  if (!array_key_exists($logic->id, $this->results)) {
56  return false;
57  }
58 
59  return $this->results[$logic->id]->evaluate($userModel, $groupModel, $roleModel);
60  }
61 }
evaluate(Logic $logic, $userModel=null, $groupModel=null, $roleModel=null)