Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
|
100.00% |
4 / 4 |
CRAP | |
100.00% |
1 / 1 |
| ProviderHandler | |
100.00% |
26 / 26 |
|
100.00% |
4 / 4 |
6 | |
100.00% |
1 / 1 |
| readResponse | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| readProviderList | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| readProviderAssigned | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |||
| readProviderNotAssigned | |
100.00% |
9 / 9 |
|
100.00% |
1 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * |
| 5 | * @copyright BerlinOnline Stadtportal GmbH & Co. KG |
| 6 | * |
| 7 | */ |
| 8 | |
| 9 | namespace BO\Zmsadmin\Helper; |
| 10 | |
| 11 | use BO\Zmsentities\Collection\ProviderList as Collection; |
| 12 | |
| 13 | class ProviderHandler extends \BO\Zmsadmin\BaseController |
| 14 | { |
| 15 | /** |
| 16 | * @SuppressWarnings(UnusedFormalParameter) |
| 17 | * @return String |
| 18 | */ |
| 19 | public function readResponse( |
| 20 | \Psr\Http\Message\RequestInterface $request, |
| 21 | \Psr\Http\Message\ResponseInterface $response, |
| 22 | array $args |
| 23 | ) { |
| 24 | return \BO\Slim\Render::withJson( |
| 25 | $response, |
| 26 | static::readProviderList($args['source']) |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | public static function readProviderList($source) |
| 31 | { |
| 32 | return [ |
| 33 | ['name' => 'assigned', 'items' => static::readProviderAssigned($source)], |
| 34 | ['name' => 'notAssigned', 'items' => static::readProviderNotAssigned($source)] |
| 35 | ]; |
| 36 | } |
| 37 | |
| 38 | protected static function readProviderAssigned($source) |
| 39 | { |
| 40 | $providerAssigned = \App::$http->readGetResult( |
| 41 | '/provider/' . $source . '/', |
| 42 | array( |
| 43 | 'isAssigned' => true |
| 44 | ) |
| 45 | )->getCollection(); |
| 46 | return ($providerAssigned) ? |
| 47 | $providerAssigned->withUniqueProvider()->sortByName() : |
| 48 | new Collection(); |
| 49 | } |
| 50 | |
| 51 | protected static function readProviderNotAssigned($source) |
| 52 | { |
| 53 | $providerNotAssigned = \App::$http->readGetResult( |
| 54 | '/provider/' . $source . '/', |
| 55 | array( |
| 56 | 'isAssigned' => false |
| 57 | ) |
| 58 | )->getCollection(); |
| 59 | return ($providerNotAssigned) ? |
| 60 | $providerNotAssigned->withUniqueProvider()->sortByName() : |
| 61 | new Collection(); |
| 62 | } |
| 63 | } |