Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
58.33% |
7 / 12 |
|
50.00% |
5 / 10 |
CRAP | |
0.00% |
0 / 1 |
| tao_helpers_form_elements_MultipleElement | |
58.33% |
7 / 12 |
|
50.00% |
5 / 10 |
19.75 | |
0.00% |
0 / 1 |
| addOptionAttribute | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| getOptionAttributes | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setOptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOptions | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setValue | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| addValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getValues | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setValues | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getDisabledValues | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| setDisabledValues | |
0.00% |
0 / 1 |
|
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) 2008-2010 (original work) Deutsche Institut für Internationale Pädagogische Forschung |
| 19 | * (under the project TAO-TRANSFER); |
| 20 | * 2009-2012 (update and modification) Public Research Centre Henri Tudor |
| 21 | * (under the project TAO-SUSTAIN & TAO-DEV); |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | declare(strict_types=1); |
| 26 | |
| 27 | /** |
| 28 | * Short description of class tao_helpers_form_elements_MultipleElement |
| 29 | * |
| 30 | * @abstract |
| 31 | * @access public |
| 32 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 33 | * @package tao |
| 34 | */ |
| 35 | abstract class tao_helpers_form_elements_MultipleElement extends tao_helpers_form_FormElement |
| 36 | { |
| 37 | /** @var array */ |
| 38 | protected $options = []; |
| 39 | |
| 40 | /** @var array */ |
| 41 | protected $values = []; |
| 42 | |
| 43 | /** @var array */ |
| 44 | private $disabledValues = []; |
| 45 | |
| 46 | /** @var array */ |
| 47 | private $optionAttributes = []; |
| 48 | |
| 49 | public function addOptionAttribute(string $optionValue, string $attribute, string $attributeValue): void |
| 50 | { |
| 51 | if (empty($this->optionAttributes[$optionValue])) { |
| 52 | $this->optionAttributes[$optionValue] = []; |
| 53 | } |
| 54 | |
| 55 | $this->optionAttributes[$optionValue][$attribute] = $attributeValue; |
| 56 | } |
| 57 | |
| 58 | public function getOptionAttributes(string $optionValue): array |
| 59 | { |
| 60 | return $this->optionAttributes[$optionValue] ?? []; |
| 61 | } |
| 62 | |
| 63 | /** |
| 64 | * Short description of method setOptions |
| 65 | * |
| 66 | * @access public |
| 67 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 68 | * @param array options |
| 69 | * @return void |
| 70 | */ |
| 71 | public function setOptions(array $options): void |
| 72 | { |
| 73 | $this->options = $options; |
| 74 | } |
| 75 | |
| 76 | /** |
| 77 | * Short description of method getOptions |
| 78 | * |
| 79 | * @access public |
| 80 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 81 | * @return array |
| 82 | */ |
| 83 | public function getOptions() |
| 84 | { |
| 85 | return (array)$this->options; |
| 86 | } |
| 87 | |
| 88 | /** |
| 89 | * Short description of method setValue |
| 90 | * |
| 91 | * @access public |
| 92 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 93 | * @param string $value |
| 94 | * @return void |
| 95 | */ |
| 96 | public function setValue($value) |
| 97 | { |
| 98 | $this->value = tao_helpers_Uri::encode((string)$value); |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Short description of method addValue |
| 103 | * |
| 104 | * @access public |
| 105 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 106 | * @param string $value |
| 107 | * @return void |
| 108 | */ |
| 109 | public function addValue(string $value): void |
| 110 | { |
| 111 | $this->values[] = tao_helpers_Uri::encode($value); |
| 112 | } |
| 113 | |
| 114 | /** |
| 115 | * Short description of method getValues |
| 116 | * |
| 117 | * @access public |
| 118 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 119 | * @return array |
| 120 | */ |
| 121 | public function getValues(): array |
| 122 | { |
| 123 | return (array)$this->values; |
| 124 | } |
| 125 | |
| 126 | /** |
| 127 | * Short description of method setValues |
| 128 | * |
| 129 | * @access public |
| 130 | * @author Bertrand Chevrier, <bertrand.chevrier@tudor.lu> |
| 131 | * @param array values |
| 132 | * @return mixed |
| 133 | */ |
| 134 | public function setValues(array $values) |
| 135 | { |
| 136 | $this->values = $values; |
| 137 | } |
| 138 | |
| 139 | public function getDisabledValues(): array |
| 140 | { |
| 141 | return $this->disabledValues; |
| 142 | } |
| 143 | |
| 144 | public function setDisabledValues(array $disabledValues): void |
| 145 | { |
| 146 | $this->disabledValues = $disabledValues; |
| 147 | } |
| 148 | } |