Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
15.38% |
2 / 13 |
|
25.00% |
1 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_models_classes_service_VariableParameter | |
15.38% |
2 / 13 |
|
25.00% |
1 / 4 |
13.69 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getVariable | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toOntology | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 | |||
| jsonSerialize | |
0.00% |
0 / 4 |
|
0.00% |
0 / 1 |
2 | |||
| 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) 2013 (original work) Open Assessment Technologies SA (under the project TAO-PRODUCT); |
| 19 | * |
| 20 | */ |
| 21 | |
| 22 | use oat\generis\model\data\Ontology; |
| 23 | use oat\tao\model\WfEngineOntology; |
| 24 | |
| 25 | /** |
| 26 | * Represents a tao service parameter that |
| 27 | * is linked to a process variable |
| 28 | * |
| 29 | * @access public |
| 30 | * @author Joel Bout, <joel@taotesting.com> |
| 31 | * @package tao |
| 32 | * phpcs:disable Squiz.Classes.ValidClassName |
| 33 | */ |
| 34 | class tao_models_classes_service_VariableParameter extends tao_models_classes_service_Parameter |
| 35 | { |
| 36 | /** |
| 37 | * @var core_kernel_classes_Resource |
| 38 | */ |
| 39 | private $variable; |
| 40 | |
| 41 | /** |
| 42 | * Instantiates an new variable parameter |
| 43 | * |
| 44 | * @param core_kernel_classes_Resource $definition |
| 45 | * @param core_kernel_classes_Resource $variable |
| 46 | */ |
| 47 | public function __construct(core_kernel_classes_Resource $definition, core_kernel_classes_Resource $variable) |
| 48 | { |
| 49 | parent::__construct($definition); |
| 50 | $this->variable = $variable; |
| 51 | } |
| 52 | |
| 53 | /** |
| 54 | * Returns the variable proividing the value |
| 55 | * for this parameter |
| 56 | * |
| 57 | * @return core_kernel_classes_Resource |
| 58 | */ |
| 59 | public function getVariable() |
| 60 | { |
| 61 | return $this->variable; |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * (non-PHPdoc) |
| 66 | * @see tao_models_classes_service_Parameter::serialize() |
| 67 | */ |
| 68 | public function toOntology(Ontology $model) |
| 69 | { |
| 70 | $serviceCallClass = $model->getClass(WfEngineOntology::CLASS_URI_ACTUAL_PARAMETER); |
| 71 | $resource = $serviceCallClass->createInstanceWithProperties([ |
| 72 | WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER => $this->getDefinition(), |
| 73 | WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_PROCESS_VARIABLE => $this->variable |
| 74 | ]); |
| 75 | return $resource; |
| 76 | } |
| 77 | |
| 78 | public function jsonSerialize(): array |
| 79 | { |
| 80 | return [ |
| 81 | 'def' => $this->getDefinition()->getUri(), |
| 82 | 'proc' => $this->getVariable()->getUri() |
| 83 | ]; |
| 84 | } |
| 85 | } |