Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
89.66% covered (warning)
89.66%
26 / 29
75.00% covered (warning)
75.00%
9 / 12
CRAP
0.00% covered (danger)
0.00%
0 / 1
Request
89.66% covered (warning)
89.66%
26 / 29
75.00% covered (warning)
75.00%
9 / 12
21.49
0.00% covered (danger)
0.00%
0 / 1
 getDefaults
100.00% covered (success)
100.00%
8 / 8
100.00% covered (success)
100.00%
1 / 1
1
 withReference
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 hasAppointmentFromProviderData
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
8
 getSource
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getGroup
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getLink
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getName
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getAdditionalData
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getParentId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 getRootParentId
100.00% covered (success)
100.00%
4 / 4
100.00% covered (success)
100.00%
1 / 1
3
 getVariantId
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 __toString
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
1<?php
2
3namespace BO\Zmsentities;
4
5class Request extends Schema\Entity
6{
7    public const string PRIMARY = 'id';
8
9    public static $schema = "request.json";
10
11    /**
12     * @return (null|string)[]
13     *
14     */
15    #[\Override]
16    public function getDefaults()
17    {
18        return [
19            'id' => '',
20            'name' => '',
21            'source' => 'dldb',
22            'parent_id' => null,
23            'root_parent_id' => null,
24            'variant_id' => null
25        ];
26    }
27
28    #[\Override]
29    public function withReference($additionalData = [])
30    {
31        $additionalData['id'] = $this->getId();
32        $additionalData['name'] = $this->getName();
33        return parent::withReference($additionalData);
34    }
35
36    public function hasAppointmentFromProviderData(): bool
37    {
38        if (isset($this['data']) && isset($this['data']['locations'])) {
39            foreach ($this['data']['locations'] as $provider) {
40                if (
41                    (!isset($provider['appointment']['external']) || !$provider['appointment']['external'])
42                    && isset($provider['appointment']['allowed']) && $provider['appointment']['allowed']
43                ) {
44                    return true;
45                }
46            }
47        }
48        return false;
49    }
50
51    public function getSource()
52    {
53        return $this->toProperty()->source->get();
54    }
55
56    public function getGroup()
57    {
58        return $this->toProperty()->group->get();
59    }
60
61    public function getLink()
62    {
63        return $this->toProperty()->link->get();
64    }
65
66    public function getName()
67    {
68        return $this->toProperty()->name->get();
69    }
70
71    public function getAdditionalData()
72    {
73        return $this->toProperty()->data->get();
74    }
75
76    public function getParentId()
77    {
78        return $this->toProperty()->parent_id->get();
79    }
80
81    public function getRootParentId(): string
82    {
83        $rootParentId = $this->toProperty()->root_parent_id->get();
84        if ($rootParentId !== null && $rootParentId !== '') {
85            return (string) $rootParentId;
86        }
87
88        return (string) $this->getId();
89    }
90
91    public function getVariantId()
92    {
93        return $this->toProperty()->variant_id->get();
94    }
95
96    public function __toString()
97    {
98        return $this->getName();
99    }
100}