Lines
0.00%
0 / 14
Functions and Methods
0.00%
0 / 2
Classes and Traits
0.00%
0 / 1
| Name | Lines | Functions and Methods | CRAP | Classes and Traits | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| UseraccountList | 0.00% | 0 / 14 | 0.00% | 0 / 2 | 56 | 0.00% | 0 / 1 | |||
| withoutDublicates | 0.00% | 0 / 5 | 0.00% | 0 / 1 | 12 | |||||
| withAccessByWorkstation | 0.00% | 0 / 9 | 0.00% | 0 / 1 | 20 | |||||
| 1 | <?php | |
| 2 | ||
| 3 | namespace BO\Zmsentities\Collection; | |
| 4 | ||
| 5 | /** | |
| 6 | * @extends Base<\BO\Zmsentities\Useraccount> | |
| 7 | */ | |
| 8 | class UseraccountList extends Base | |
| 9 | { | |
| 10 | public const string ENTITY_CLASS = '\BO\Zmsentities\UserAccount'; | |
| 11 | ||
| 12 | public function withoutDublicates(): self | |
| 13 | { | |
| 14 | $collection = new self(); | |
| 15 | foreach ($this as $useraccount) { | |
| 16 | if (! $collection->hasEntity($useraccount->getId())) { | |
| 17 | $collection->addEntity($useraccount); | |
| 18 | } | |
| 19 | } | |
| 20 | return $collection; | |
| 21 | } | |
| 22 | ||
| 23 | public function withAccessByWorkstation(mixed $workstation): self | |
| 24 | { | |
| 25 | $collection = new self(); | |
| 26 | $departmentList = $workstation->getDepartmentList(); | |
| 27 | foreach ($this as $useraccount) { | |
| 28 | if ($useraccount->hasPermissions(['department'])) { | |
| 29 | $accessedList = $departmentList; | |
| 30 | } else { | |
| 31 | $accessedList = $departmentList->withAccess($useraccount); | |
| 32 | } | |
| 33 | ||
| 34 | if ($accessedList->count()) { | |
| 35 | $collection->addEntity($useraccount); | |
| 36 | } | |
| 37 | } | |
| 38 | return $collection; | |
| 39 | } | |
| 40 | } |