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