Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
20.00% |
3 / 15 |
|
0.00% |
0 / 4 |
CRAP | |
0.00% |
0 / 1 |
| tao_models_classes_service_ConstantParameter | |
20.00% |
3 / 15 |
|
0.00% |
0 / 4 |
24.43 | |
0.00% |
0 / 1 |
| __construct | |
75.00% |
3 / 4 |
|
0.00% |
0 / 1 |
3.14 | |||
| getValue | |
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\tao\model\WfEngineOntology; |
| 23 | use oat\generis\model\data\Ontology; |
| 24 | |
| 25 | /** |
| 26 | * Represents tao service parameter |
| 27 | * |
| 28 | * @access public |
| 29 | * @author Joel Bout, <joel@taotesting.com> |
| 30 | * @package tao |
| 31 | * phpcs:disable Squiz.Classes.ValidClassName |
| 32 | */ |
| 33 | class tao_models_classes_service_ConstantParameter extends tao_models_classes_service_Parameter |
| 34 | { |
| 35 | /** |
| 36 | * @var string |
| 37 | */ |
| 38 | private $value; |
| 39 | |
| 40 | /** |
| 41 | * Instantiates a parameter that takes |
| 42 | * a constant value |
| 43 | * |
| 44 | * @param core_kernel_classes_Resource $definition |
| 45 | * @param string $value |
| 46 | */ |
| 47 | public function __construct(core_kernel_classes_Resource $definition, $value) |
| 48 | { |
| 49 | parent::__construct($definition); |
| 50 | $this->value = is_object($value) && $value instanceof core_kernel_classes_Resource |
| 51 | ? $value->getUri() |
| 52 | : (string)$value; |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Returns the actual value associated to this parameter |
| 57 | * |
| 58 | * @return string |
| 59 | */ |
| 60 | public function getValue() |
| 61 | { |
| 62 | return $this->value; |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * (non-PHPdoc) |
| 67 | * @see tao_models_classes_service_Parameter::serialize() |
| 68 | */ |
| 69 | public function toOntology(Ontology $model) |
| 70 | { |
| 71 | $serviceCallClass = $model->getClass(WfEngineOntology::CLASS_URI_ACTUAL_PARAMETER); |
| 72 | $resource = $serviceCallClass->createInstanceWithProperties([ |
| 73 | WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_FORMAL_PARAMETER => $this->getDefinition(), |
| 74 | WfEngineOntology::PROPERTY_ACTUAL_PARAMETER_CONSTANT_VALUE => $this->value |
| 75 | ]); |
| 76 | return $resource; |
| 77 | } |
| 78 | |
| 79 | public function jsonSerialize(): array |
| 80 | { |
| 81 | return [ |
| 82 | 'def' => $this->getDefinition()->getUri(), |
| 83 | 'const' => $this->getValue() |
| 84 | ]; |
| 85 | } |
| 86 | } |