Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
5 / 5
CRAP
100.00% covered (success)
100.00%
1 / 1
Owner
100.00% covered (success)
100.00%
16 / 16
100.00% covered (success)
100.00%
5 / 5
9
100.00% covered (success)
100.00%
1 / 1
 getDefaults
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
1
 hasOrganisation
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOrganisationList
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
3
 hasAccess
100.00% covered (success)
100.00%
2 / 2
100.00% covered (success)
100.00%
1 / 1
2
 withLessData
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
2
1<?php
2
3namespace BO\Zmsentities;
4
5class Owner extends Schema\Entity implements Useraccount\AccessInterface
6{
7    public const PRIMARY = 'id';
8
9    public static $schema = "owner.json";
10
11    #[\Override]
12    public function getDefaults()
13    {
14        return [
15            'organisations' => new Collection\OrganisationList(),
16            'name' => '',
17            ];
18    }
19
20    public function hasOrganisation($organisationId)
21    {
22        return $this->getOrganisationList()->hasEntity($organisationId);
23    }
24
25    public function getOrganisationList()
26    {
27        if (!$this->organisations instanceof Collection\OrganisationList) {
28            $this->organisations = new Collection\OrganisationList($this->organisations);
29            foreach ($this->organisations as $key => $organisation) {
30                $this->organisations[$key] = new Organisation($organisation);
31            }
32        }
33        return $this->organisations;
34    }
35
36
37    #[\Override]
38    public function hasAccess(Useraccount $useraccount)
39    {
40        return $useraccount->hasRights(['superuser'])
41            || 0 < $this->getOrganisationList()->withAccess($useraccount)->count();
42    }
43
44    /**
45     * Reduce data of dereferenced entities to a required minimum
46     *
47     */
48    #[\Override]
49    public function withLessData()
50    {
51        $entity = clone $this;
52        if ($entity->toProperty()->organisations->isAvailable()) {
53            unset($entity['organisations']);
54        }
55        return $entity;
56    }
57}