Bristol SU Support Package
src
Testing
LogicTester
LogicTesterFake.php
Go to the documentation of this file.
1
<?php
2
3
namespace
BristolSU\Support\Testing\LogicTester
;
4
5
use
BristolSU\ControlDB\Contracts\Models\Group
;
6
use
BristolSU\ControlDB\Contracts\Models\Role
;
7
use
BristolSU\ControlDB\Contracts\Models\User
;
8
use
BristolSU\Support\Logic\Contracts\LogicTester
;
9
use
BristolSU\Support\Logic\Logic
;
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
}
BristolSU\Support\Testing\LogicTester\LogicTesterResult
Definition:
LogicTesterResult.php:13
BristolSU\Support\Testing\LogicTester
Definition:
LogicTesterFake.php:3
BristolSU\Support\Logic\Contracts\LogicTester
Definition:
LogicTester.php:13
User
BristolSU\Support\Testing\LogicTester\LogicTesterFake\evaluate
evaluate(Logic $logic, $userModel=null, $groupModel=null, $roleModel=null)
Definition:
LogicTesterFake.php:53
Group
BristolSU\Support\Testing\LogicTester\LogicTesterFake
Definition:
LogicTesterFake.php:14
BristolSU\Support\Logic\Logic
Definition:
Logic.php:16
BristolSU\Support\Testing\LogicTester\LogicTesterFake\$results
$results
Definition:
LogicTesterFake.php:22
Role
LogicTester
Logic
BristolSU\Support\Testing\LogicTester\LogicTesterFake\forLogic
forLogic(Logic $logic)
Definition:
LogicTesterFake.php:30
BristolSU\Support\Testing\LogicTester\LogicTesterFake\bind
bind()
Definition:
LogicTesterFake.php:38
Generated by
1.8.13