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 PRIMARY = 'id';
8
9    public static $schema = "request.json";
10
11    #[\Override]
12    public function getDefaults()
13    {
14        return [
15            'id' => '',
16            'name' => '',
17            'source' => 'dldb',
18            'parent_id' => null,
19            'root_parent_id' => null,
20            'variant_id' => null
21        ];
22    }
23
24    #[\Override]
25    public function withReference($additionalData = [])
26    {
27        $additionalData['id'] = $this->getId();
28        $additionalData['name'] = $this->getName();
29        return parent::withReference($additionalData);
30    }
31
32    public function hasAppointmentFromProviderData()
33    {
34        if (isset($this['data']) && isset($this['data']['locations'])) {
35            foreach ($this['data']['locations'] as $provider) {
36                if (
37                    (!isset($provider['appointment']['external']) || !$provider['appointment']['external'])
38                    && isset($provider['appointment']['allowed']) && $provider['appointment']['allowed']
39                ) {
40                    return true;
41                }
42            }
43        }
44        return false;
45    }
46
47    public function getSource()
48    {
49        return $this->toProperty()->source->get();
50    }
51
52    public function getGroup()
53    {
54        return $this->toProperty()->group->get();
55    }
56
57    public function getLink()
58    {
59        return $this->toProperty()->link->get();
60    }
61
62    public function getName()
63    {
64        return $this->toProperty()->name->get();
65    }
66
67    public function getAdditionalData()
68    {
69        return $this->toProperty()->data->get();
70    }
71
72    public function getParentId()
73    {
74        return $this->toProperty()->parent_id->get();
75    }
76
77    public function getRootParentId(): string
78    {
79        $rootParentId = $this->toProperty()->root_parent_id->get();
80        if ($rootParentId !== null && $rootParentId !== '') {
81            return (string) $rootParentId;
82        }
83
84        return (string) $this->getId();
85    }
86
87    public function getVariantId()
88    {
89        return $this->toProperty()->variant_id->get();
90    }
91
92    public function __toString()
93    {
94        return $this->getName();
95    }
96}