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