Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
94.29% |
33 / 35 |
|
81.82% |
9 / 11 |
CRAP | |
0.00% |
0 / 1 |
Provider | |
94.29% |
33 / 35 |
|
81.82% |
9 / 11 |
20.07 | |
0.00% |
0 / 1 |
getDefaults | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
addData | |
100.00% |
11 / 11 |
|
100.00% |
1 / 1 |
7 | |||
hasRequest | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getRequestList | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
4 | |||
getSource | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getName | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getDisplayName | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
getContact | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
getLink | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getAdditionalData | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
getSlotTimeInMinutes | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace BO\Zmsentities; |
4 | |
5 | class Provider extends Schema\Entity |
6 | { |
7 | public const PRIMARY = 'id'; |
8 | |
9 | public static $schema = "provider.json"; |
10 | |
11 | public function getDefaults() |
12 | { |
13 | return [ |
14 | 'id' => 0, |
15 | 'name' => '', |
16 | 'source' => 'dldb' |
17 | ]; |
18 | } |
19 | |
20 | public function addData($input) |
21 | { |
22 | $refString = '$ref'; |
23 | if ( |
24 | (is_array($input) || $input instanceof \ArrayAccess) |
25 | && isset($input[$refString]) |
26 | && (!isset($input['id']) || !isset($input['source'])) |
27 | ) { |
28 | $providerRef = $input[$refString]; |
29 | $providerId = preg_replace('#^.*/(\d+)/$#', '$1', $providerRef); |
30 | $input['id'] = $providerId; |
31 | $input['source'] = preg_replace('#^.*provider/([^/]+)/\d+/$#', '$1', $providerRef); |
32 | } |
33 | if (isset($input[$refString])) { |
34 | unset($input[$refString]); |
35 | } |
36 | return parent::addData($input); |
37 | } |
38 | |
39 | public function hasRequest($requestId) |
40 | { |
41 | return $this->getRequestList()->hasRequests($requestId); |
42 | } |
43 | |
44 | public function getRequestList() |
45 | { |
46 | $requestList = new \BO\Zmsentities\Collection\RequestList(); |
47 | if (isset($this['data']['services'])) { |
48 | foreach ($this['data']['services'] as $item) { |
49 | $request = new Request([ |
50 | 'id' => $item['service'], |
51 | 'source' => 'dldb', |
52 | 'link' => isset($item['url']) ? $item['url'] : '', |
53 | ]); |
54 | $requestList->addEntity($request); |
55 | } |
56 | } |
57 | return $requestList; |
58 | } |
59 | |
60 | public function getSource() |
61 | { |
62 | return $this->toProperty()->source->get(); |
63 | } |
64 | |
65 | public function getName() |
66 | { |
67 | return $this->toProperty()->name->get(); |
68 | } |
69 | |
70 | public function getDisplayName() |
71 | { |
72 | return $this->toProperty()->display_name->get(); |
73 | } |
74 | |
75 | public function getContact() |
76 | { |
77 | $contact = $this->toProperty()->contact->get(); |
78 | return new Contact($contact); |
79 | } |
80 | |
81 | public function getLink() |
82 | { |
83 | return $this->toProperty()->link->get(); |
84 | } |
85 | |
86 | public function getAdditionalData() |
87 | { |
88 | return $this->toProperty()->data->get(); |
89 | } |
90 | |
91 | public function getSlotTimeInMinutes() |
92 | { |
93 | return $this->getAdditionalData()['slotTimeInMinutes']; |
94 | } |
95 | } |