Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
100.00% |
28 / 28 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
Matching | |
100.00% |
28 / 28 |
|
100.00% |
4 / 4 |
11 | |
100.00% |
1 / 1 |
hasProviderRequest | |
100.00% |
10 / 10 |
|
100.00% |
1 / 1 |
3 | |||
isProviderExisting | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
2 | |||
isRequestExisting | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 | |||
testCurrentScopeHasRequest | |
100.00% |
6 / 6 |
|
100.00% |
1 / 1 |
3 |
1 | <?php |
2 | |
3 | namespace BO\Zmsapi\Helper; |
4 | |
5 | use BO\Mellon\Validator; |
6 | use BO\Zmsdb\Provider; |
7 | use BO\Zmsdb\Request; |
8 | |
9 | /** |
10 | * example class to generate a response |
11 | */ |
12 | class Matching |
13 | { |
14 | public static function hasProviderRequest($session) |
15 | { |
16 | $result = true; |
17 | $requestIdCsv = $session->getRequests(); |
18 | $providerList = (new Provider())->readListBySource($session->getSource(), 0, null, $requestIdCsv); |
19 | if ($session->hasProvider()) { |
20 | $providerIdCsv = $session->getProviders(); |
21 | $result = $providerList->hasProvider($providerIdCsv); |
22 | } elseif ($session->hasScope()) { |
23 | $scope = (new \BO\Zmsdb\Scope())->readEntity($session->getScope(), 1); |
24 | $result = $providerList->hasProvider($scope->getProviderId()); |
25 | } |
26 | return $result; |
27 | } |
28 | |
29 | public static function isProviderExisting($session) |
30 | { |
31 | $result = true; |
32 | if ($session->hasProvider()) { |
33 | $providerIdCsv = $session->getProviders(); |
34 | $providerList = (new Provider())->readListBySource($session->getSource()); |
35 | $result = $providerList->hasProvider($providerIdCsv); |
36 | } |
37 | return $result; |
38 | } |
39 | |
40 | public static function isRequestExisting($session) |
41 | { |
42 | $result = true; |
43 | if ($session->hasRequests()) { |
44 | $requestIdCsv = $session->getRequests(); |
45 | $providerList = (new Provider())->readListBySource($session->getSource(), 1, null, $requestIdCsv); |
46 | $result = (count($providerList)) ? true : false; |
47 | } |
48 | return $result; |
49 | } |
50 | |
51 | public static function testCurrentScopeHasRequest($process) |
52 | { |
53 | $testProcess = clone $process; |
54 | $scope = (new \BO\Zmsdb\Scope())->readEntity($testProcess->getScopeId(), 2); |
55 | $testProcess->scope = $scope; |
56 | if ( |
57 | 0 < count($testProcess->getRequestIds()) && |
58 | !$testProcess->getCurrentScope()->getRequestList()->hasRequests($testProcess->getRequestCSV()) |
59 | ) { |
60 | throw new \BO\Zmsapi\Exception\Matching\RequestNotFound(); |
61 | } |
62 | } |
63 | } |