1 <?php
2
3 namespace Docoflow\Entity;
4
5 use Exception;
6 use Docoflow\Traits\Entity;
7 use Docolight\Support\Collection;
8 use Docoflow\Traits\BulkValidator;
9
10 11 12 13 14
15 class Verificator extends Collection
16 {
17 use Entity, BulkValidator;
18
19 20 21 22 23
24 public function rebuild(Step &$steps)
25 {
26 foreach ($this as $verificator) {
27 $verificator = fluent($verificator);
28
29 if (! $assignedGroup = $verificator->{'$group'}) {
30 throw new Exception("Verificator hasn't assigned to any group.");
31 }
32
33 if ($steps->hasGroup($assignedGroup)) {
34 $verificatorStep = $steps->getGroup($assignedGroup)->{'$step'};
35
36 $steps
37 ->get($verificatorStep)->groups
38 ->get($assignedGroup)->verificator
39 ->push($verificator);
40 } else {
41 throw new Exception("Assigned group [$assignedGroup] doent't exist.");
42 }
43 }
44 }
45 }
46