Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 1 |
| RemoteList | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
12 | |
0.00% |
0 / 1 |
| getList | |
0.00% |
0 / 13 |
|
0.00% |
0 / 1 |
12 | |||
| 1 | <?php |
| 2 | |
| 3 | /** |
| 4 | * This program is free software; you can redistribute it and/or |
| 5 | * modify it under the terms of the GNU General Public License |
| 6 | * as published by the Free Software Foundation; under version 2 |
| 7 | * of the License (non-upgradable). |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
| 17 | * |
| 18 | * Copyright (c) 2021 (original work) Open Assessment Technologies SA; |
| 19 | */ |
| 20 | |
| 21 | declare(strict_types=1); |
| 22 | |
| 23 | namespace oat\taoClientDiagnostic\model\SupportedList; |
| 24 | |
| 25 | use oat\oatbox\service\ConfigurableService; |
| 26 | use oat\taoClientDiagnostic\model\diagnostic\DiagnosticServiceInterface; |
| 27 | |
| 28 | class RemoteList extends ConfigurableService implements SupportedListInterface |
| 29 | { |
| 30 | public function getList(): ?array |
| 31 | { |
| 32 | $service = $this->getServiceLocator()->get(DiagnosticServiceInterface::SERVICE_ID); |
| 33 | $config = $service->getDiagnosticJsConfig(); |
| 34 | $supportListUrl = $config['diagnostic']['testers']['browser']['browserslistUrl']; |
| 35 | |
| 36 | if (!$supportListUrl) { |
| 37 | throw new \common_exception_MissingParameter('The URL to the list of supported browser is not configured'); |
| 38 | } |
| 39 | |
| 40 | $supportedListData = @file_get_contents($supportListUrl); |
| 41 | if ($supportedListData === false) { |
| 42 | $error = error_get_last(); |
| 43 | throw new \common_exception_FileSystemError(sprintf( |
| 44 | 'Unable to fetch the list of supported browsers due to error: %s', |
| 45 | $error['message'] |
| 46 | )); |
| 47 | } |
| 48 | |
| 49 | return json_decode($supportedListData, true); |
| 50 | } |
| 51 | } |