Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
CRAP | |
0.00% |
0 / 1 |
| LtiDeliveryFactory | |
75.00% |
3 / 4 |
|
50.00% |
1 / 2 |
3.14 | |
0.00% |
0 / 1 |
| create | |
66.67% |
2 / 3 |
|
0.00% |
0 / 1 |
2.15 | |||
| getLTIDeliveryTool | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 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) 2019 (original work) Open Assessment Technologies SA; |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | namespace oat\ltiDeliveryProvider\model; |
| 23 | |
| 24 | use core_kernel_classes_Container; |
| 25 | use core_kernel_classes_Resource; |
| 26 | use oat\generis\model\OntologyAwareTrait; |
| 27 | use oat\oatbox\service\ConfigurableService; |
| 28 | |
| 29 | class LtiDeliveryFactory extends ConfigurableService |
| 30 | { |
| 31 | use OntologyAwareTrait; |
| 32 | |
| 33 | public const SERVICE_ID = 'ltiDeliveryProvider/LtiDeliveryFactory'; |
| 34 | |
| 35 | /** |
| 36 | * @param string $uri |
| 37 | * |
| 38 | * @return core_kernel_classes_Container|core_kernel_classes_Resource |
| 39 | */ |
| 40 | public function create($uri) |
| 41 | { |
| 42 | return $uri !== null |
| 43 | ? $this->getResource($uri) |
| 44 | : $this->getLTIDeliveryTool()->getDeliveryFromLink(); |
| 45 | } |
| 46 | |
| 47 | /** |
| 48 | * @return LTIDeliveryTool |
| 49 | */ |
| 50 | private function getLTIDeliveryTool() |
| 51 | { |
| 52 | return $this->getServiceLocator()->get(LTIDeliveryToolFactory::SERVICE_ID)->create(); |
| 53 | } |
| 54 | } |