| @@ -1,66 +1,121 @@ | ||
| 1 | 1 | <?php |
| 2 | - | |
| 3 | -declare(strict_types=1); | |
| 4 | - | |
| 2 | +/** | |
| 3 | + * FormFactory.php | |
| 4 | + * | |
| 5 | + * The FormFactory class file. | |
| 6 | + * | |
| 7 | + * PHP versions 5 | |
| 8 | + * | |
| 9 | + * @author Alexander Schneider <[email protected]> | |
| 10 | + * @copyright 2008-2017 Alexander Schneider | |
| 11 | + * @license http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License, version 2 | |
| 12 | + * @version SVN: $id$ | |
| 13 | + * @link http://wordpress.org/extend/plugins/user-access-manager/ | |
| 14 | + */ | |
| 5 | 15 | namespace UserAccessManager\Form; |
| 6 | 16 | |
| 7 | -use Exception; | |
| 8 | - | |
| 17 | +/** | |
| 18 | + * Class FormFactory | |
| 19 | + * | |
| 20 | + * @package UserAccessManager\Form | |
| 21 | + */ | |
| 9 | 22 | class FormFactory |
| 10 | 23 | { |
| 11 | - public function createFrom(): Form | |
| 24 | + /** | |
| 25 | + * Creates a form object. | |
| 26 | + * | |
| 27 | + * @return Form | |
| 28 | + */ | |
| 29 | + public function createFrom() | |
| 12 | 30 | { |
| 13 | 31 | return new Form(); |
| 14 | 32 | } |
| 15 | 33 | |
| 16 | - public function createValueSetFromElementValue(mixed $value, string $label): ValueSetFormElementValue | |
| 34 | + /** | |
| 35 | + * Creates a ValueSetFormElementValue object. | |
| 36 | + * | |
| 37 | + * @param mixed $value | |
| 38 | + * @param string $label | |
| 39 | + * | |
| 40 | + * @return ValueSetFormElementValue | |
| 41 | + */ | |
| 42 | + public function createValueSetFromElementValue($value, $label) | |
| 17 | 43 | { |
| 18 | 44 | return new ValueSetFormElementValue($value, $label); |
| 19 | 45 | } |
| 20 | 46 | |
| 21 | - public function createMultipleFormElementValue(mixed $value, string $label): MultipleFormElementValue | |
| 47 | + /** | |
| 48 | + * Creates a MultipleFormElementValue object. | |
| 49 | + * | |
| 50 | + * @param mixed $value | |
| 51 | + * @param string $label | |
| 52 | + * | |
| 53 | + * @return MultipleFormElementValue | |
| 54 | + */ | |
| 55 | + public function createMultipleFormElementValue($value, $label) | |
| 22 | 56 | { |
| 23 | 57 | return new MultipleFormElementValue($value, $label); |
| 24 | 58 | } |
| 25 | 59 | |
| 26 | - public function createInput( | |
| 27 | - string $id, | |
| 28 | - mixed $value = null, | |
| 29 | - ?string $label = null, | |
| 30 | - ?string $description = null | |
| 31 | - ): Input { | |
| 60 | + /** | |
| 61 | + * Creates a Input object. | |
| 62 | + * | |
| 63 | + * @param string $id | |
| 64 | + * @param null|mixed $value | |
| 65 | + * @param null|string $label | |
| 66 | + * @param null|string $description | |
| 67 | + * | |
| 68 | + * @return Input | |
| 69 | + */ | |
| 70 | + public function createInput($id, $value = null, $label = null, $description = null) | |
| 71 | + { | |
| 32 | 72 | return new Input($id, $value, $label, $description); |
| 33 | 73 | } |
| 34 | 74 | |
| 35 | - public function createTextarea( | |
| 36 | - string $id, | |
| 37 | - mixed $value = null, | |
| 38 | - ?string $label = null, | |
| 39 | - ?string $description = null | |
| 40 | - ): Textarea { | |
| 75 | + /** | |
| 76 | + * Creates a Textarea object. | |
| 77 | + * | |
| 78 | + * @param string $id | |
| 79 | + * @param null|mixed $value | |
| 80 | + * @param null|string $label | |
| 81 | + * @param null|string $description | |
| 82 | + * | |
| 83 | + * @return Textarea | |
| 84 | + */ | |
| 85 | + public function createTextarea($id, $value = null, $label = null, $description = null) | |
| 86 | + { | |
| 41 | 87 | return new Textarea($id, $value, $label, $description); |
| 42 | 88 | } |
| 43 | 89 | |
| 44 | - public function createSelect( | |
| 45 | - string $id, | |
| 46 | - array $possibleValues, | |
| 47 | - mixed $value = null, | |
| 48 | - ?string $label = null, | |
| 49 | - ?string $description = null | |
| 50 | - ): Select { | |
| 90 | + /** | |
| 91 | + * Creates a Select object. | |
| 92 | + * | |
| 93 | + * @param string $id | |
| 94 | + * @param ValueSetFormElementValue[] $possibleValues | |
| 95 | + * @param null|mixed $value | |
| 96 | + * @param null|string $label | |
| 97 | + * @param null|string $description | |
| 98 | + * | |
| 99 | + * @return Select | |
| 100 | + */ | |
| 101 | + public function createSelect($id, array $possibleValues, $value = null, $label = null, $description = null) | |
| 102 | + { | |
| 51 | 103 | return new Select($id, $possibleValues, $value, $label, $description); |
| 52 | 104 | } |
| 53 | 105 | |
| 54 | 106 | /** |
| 55 | - * @throws Exception | |
| 107 | + * Creates a Radio object. | |
| 108 | + * | |
| 109 | + * @param string $id | |
| 110 | + * @param MultipleFormElementValue[] $possibleValues | |
| 111 | + * @param null|mixed $value | |
| 112 | + * @param null|string $label | |
| 113 | + * @param null|string $description | |
| 114 | + * | |
| 115 | + * @return Radio | |
| 56 | 116 | */ |
| 57 | - public function createRadio( | |
| 58 | - string $id, | |
| 59 | - array $possibleValues, | |
| 60 | - mixed $value = null, | |
| 61 | - ?string $label = null, | |
| 62 | - ?string $description = null | |
| 63 | - ): Radio { | |
| 117 | + public function createRadio($id, array $possibleValues, $value = null, $label = null, $description = null) | |
| 118 | + { | |
| 64 | 119 | return new Radio($id, $possibleValues, $value, $label, $description); |
| 65 | 120 | } |
| 66 | 121 | } |