From aa49c785c572afb2954e6e0ba1293401b0f0518f Mon Sep 17 00:00:00 2001 From: jedi58 Date: Sat, 7 May 2016 15:26:49 -0400 Subject: [PATCH] Applied fixes from StyleCI --- src/Inachis/Common/Form/AbstractFormType.php | 192 +++++----- .../Common/Form/Fields/AbstractSelectType.php | 1 + src/Inachis/Common/Form/Fields/ButtonType.php | 1 + src/Inachis/Common/Form/Fields/ChoiceType.php | 1 + .../Common/Form/Fields/FileUploadType.php | 1 + src/Inachis/Common/Form/Fields/HiddenType.php | 1 + src/Inachis/Common/Form/Fields/NumberType.php | 1 + .../Form/Fields/SelectOptionGroupType.php | 3 +- .../Common/Form/Fields/SelectOptionType.php | 1 + src/Inachis/Common/Form/Fields/SelectType.php | 1 + .../Common/Form/Fields/TextAreaType.php | 1 + src/Inachis/Common/Form/Fields/TextType.php | 1 + src/Inachis/Common/Form/FormBuilder.php | 166 ++++---- src/Inachis/Common/Form/FormComponent.php | 357 +++++++++--------- .../Common/Form/FormComponentInterface.php | 30 +- 15 files changed, 385 insertions(+), 373 deletions(-) diff --git a/src/Inachis/Common/Form/AbstractFormType.php b/src/Inachis/Common/Form/AbstractFormType.php index 2bd21f54..8a94026a 100644 --- a/src/Inachis/Common/Form/AbstractFormType.php +++ b/src/Inachis/Common/Form/AbstractFormType.php @@ -10,93 +10,93 @@ */ abstract class AbstractFormType { - /** - * @var string The id of the element - */ - protected $id; - /** - * @var string The name of the element - */ - protected $name; - /** - * @var string[] The array of classes to apply to the object - */ - protected $cssClasses = array(); - /** - * @var string[] Array of attributes for the element; e.g. 'item' => 'test' - * would be output as `data-item="test"` by the view - */ - protected $dataAttributes = array(); + /** + * @var string The id of the element + */ + protected $id; + /** + * @var string The name of the element + */ + protected $name; + /** + * @var string[] The array of classes to apply to the object + */ + protected $cssClasses = array(); + /** + * @var string[] Array of attributes for the element; e.g. 'item' => 'test' + * would be output as `data-item="test"` by the view + */ + protected $dataAttributes = array(); /** * Returns the type of the current element * @return string The type of the current element */ - abstract public function getType(); - /** - * Sets the ID for the current form element - * @var string $value The new ID for the form - * @return AbstractFormType A reference to itself - * @throws FormBuilderConfigurationException - */ - public function setId($value) - { - if (!empty($value) && !preg_match('/^[a-zA-Z0-9\-\_]+$/', $value)) { - throw new FormBuilderConfigurationException(sprintf('Invalid id attribute \'%s\'.', $value)); - } - $this->id = $value; + abstract public function getType(); + /** + * Sets the ID for the current form element + * @var string $value The new ID for the form + * @return AbstractFormType A reference to itself + * @throws FormBuilderConfigurationException + */ + public function setId($value) + { + if (!empty($value) && !preg_match('/^[a-zA-Z0-9\-\_]+$/', $value)) { + throw new FormBuilderConfigurationException(sprintf('Invalid id attribute \'%s\'.', $value)); + } + $this->id = $value; return $this; - } - /** - * Returns the ID of the current form element - * @return string The ID of the form element - */ - public function getId() - { - return $this->id; - } - /** - * Sets the name for the current form element - * @var string $value The new name for the form - * @return AbstractFormType A reference to itself - * @throws FormBuilderConfigurationException - */ - public function setName($value) - { - if (!$this->isValidName($value)) { - throw new FormBuilderConfigurationException(sprintf('Invalid name attribute \'%s\'.', $value)); - } - if (in_array($this->getType(), array('checkbox', 'radio')) && !mb_strpos($value, '[]')) { - $value .= '[]'; - } - $this->name = $value; + } + /** + * Returns the ID of the current form element + * @return string The ID of the form element + */ + public function getId() + { + return $this->id; + } + /** + * Sets the name for the current form element + * @var string $value The new name for the form + * @return AbstractFormType A reference to itself + * @throws FormBuilderConfigurationException + */ + public function setName($value) + { + if (!$this->isValidName($value)) { + throw new FormBuilderConfigurationException(sprintf('Invalid name attribute \'%s\'.', $value)); + } + if (in_array($this->getType(), array('checkbox', 'radio')) && !mb_strpos($value, '[]')) { + $value .= '[]'; + } + $this->name = $value; return $this; - } - /** - * Returns the name of the current form element - * @return string The name of the form element - */ - public function getName() - { - return $this->name; - } + } + /** + * Returns the name of the current form element + * @return string The name of the form element + */ + public function getName() + { + return $this->name; + } /** - * Sets the array of CSS classes to apply to the element - * @var string[] $value The CSS to apply to the element - * @return AbstractFormType A reference to itself - * @throws FormBuilderConfigurationException + * Sets the array of CSS classes to apply to the element + * @var string[] $value The CSS to apply to the element + * @return AbstractFormType A reference to itself + * @throws FormBuilderConfigurationException */ public function setCssClasses($value) { - if (!is_array($value)) { - throw new FormBuilderConfigurationException(sprintf('Array required, %s provided', gettype($value))); - } - $this->cssClasses = $value; - return $this; + if (!is_array($value)) { + throw new FormBuilderConfigurationException(sprintf('Array required, %s provided', gettype($value))); + } + $this->cssClasses = $value; + return $this; } public function setCssClassesFromString($value) { - $this->cssClasses = explode(' ', $value); - return $this; + $this->cssClasses = explode(' ', $value); + return $this; } /** * Returns the array of CSS classes for the form element @@ -104,7 +104,7 @@ public function setCssClassesFromString($value) */ public function getCssClasses() { - return $this->cssClasses; + return $this->cssClasses; } /** * Returns the array of CSS classes as a string so it can be used @@ -113,37 +113,37 @@ public function getCssClasses() */ public function getCssClassesAsString() { - return implode(' ', $this->cssClasses); + return implode(' ', $this->cssClasses); } /** - * Adds a CSS classname to the form element - * @var string $value The CSS class to add - * @return AbstractFormType A reference to itself - * @throws FormBuilderConfigurationException + * Adds a CSS classname to the form element + * @var string $value The CSS class to add + * @return AbstractFormType A reference to itself + * @throws FormBuilderConfigurationException */ public function addCssClass($value) { - if (!$this->isValidName($value)) { - throw new FormBuilderConfigurationException(sprintf('Class name \'%s\' is invalid', $value)); - } - $this->cssClasses[] = $value; - return $this; + if (!$this->isValidName($value)) { + throw new FormBuilderConfigurationException(sprintf('Class name \'%s\' is invalid', $value)); + } + $this->cssClasses[] = $value; + return $this; } /** - * Removes a CSS classname to the form element - * @var string $value The CSS class to remove - * @return AbstractFormType A reference to itself - * @throws FormBuilderConfigurationException + * Removes a CSS classname to the form element + * @var string $value The CSS class to remove + * @return AbstractFormType A reference to itself + * @throws FormBuilderConfigurationException */ public function removeCssClass($value) { - if (!isset($this->cssClasses[$value])) { - throw new FormBuilderConfigurationException( - sprintf('Class \'%s\' does not exist - could not be removed', $value) - ); - } - unset($this->cssClasses[$value]); - return $this; + if (!isset($this->cssClasses[$value])) { + throw new FormBuilderConfigurationException( + sprintf('Class \'%s\' does not exist - could not be removed', $value) + ); + } + unset($this->cssClasses[$value]); + return $this; } /** * Validates the name for the form to confirm it's valid in HTML diff --git a/src/Inachis/Common/Form/Fields/AbstractSelectType.php b/src/Inachis/Common/Form/Fields/AbstractSelectType.php index cbe64d20..ffe9a0fd 100644 --- a/src/Inachis/Common/Form/Fields/AbstractSelectType.php +++ b/src/Inachis/Common/Form/Fields/AbstractSelectType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling select fields */ diff --git a/src/Inachis/Common/Form/Fields/ButtonType.php b/src/Inachis/Common/Form/Fields/ButtonType.php index ab448e95..28971fe1 100644 --- a/src/Inachis/Common/Form/Fields/ButtonType.php +++ b/src/Inachis/Common/Form/Fields/ButtonType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling `type="button|submit"` buttons */ diff --git a/src/Inachis/Common/Form/Fields/ChoiceType.php b/src/Inachis/Common/Form/Fields/ChoiceType.php index ad78d6a2..3bb3f37f 100644 --- a/src/Inachis/Common/Form/Fields/ChoiceType.php +++ b/src/Inachis/Common/Form/Fields/ChoiceType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling `type="checkbox"` fields */ diff --git a/src/Inachis/Common/Form/Fields/FileUploadType.php b/src/Inachis/Common/Form/Fields/FileUploadType.php index 63ae38d5..eda93064 100644 --- a/src/Inachis/Common/Form/Fields/FileUploadType.php +++ b/src/Inachis/Common/Form/Fields/FileUploadType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling `type="file"` fields */ diff --git a/src/Inachis/Common/Form/Fields/HiddenType.php b/src/Inachis/Common/Form/Fields/HiddenType.php index 20e7a54a..e6338668 100644 --- a/src/Inachis/Common/Form/Fields/HiddenType.php +++ b/src/Inachis/Common/Form/Fields/HiddenType.php @@ -3,6 +3,7 @@ namespace Inachis\Component\Common\Form\Fields; use Inachis\Component\Common\Form\FormComponent; + /** * Object for handling `type="hidden"` buttons */ diff --git a/src/Inachis/Common/Form/Fields/NumberType.php b/src/Inachis/Common/Form/Fields/NumberType.php index c6d4c2c1..83e15d43 100644 --- a/src/Inachis/Common/Form/Fields/NumberType.php +++ b/src/Inachis/Common/Form/Fields/NumberType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling `type="date|datetime|datetime-local"` fields */ diff --git a/src/Inachis/Common/Form/Fields/SelectOptionGroupType.php b/src/Inachis/Common/Form/Fields/SelectOptionGroupType.php index 84a1d559..1185c66d 100644 --- a/src/Inachis/Common/Form/Fields/SelectOptionGroupType.php +++ b/src/Inachis/Common/Form/Fields/SelectOptionGroupType.php @@ -3,6 +3,7 @@ namespace Inachis\Component\Common\Form\Fields; use Inachis\Component\Common\Form\FormComponent; + /** * Object for handling select fields */ @@ -54,6 +55,6 @@ public function getLabel() */ public function getLabelAsId() { - return preg_replace('/[^a-zA-Z0-9\-\_]/','', lcfirst(ucwords(strtolower($this->label)))); + return preg_replace('/[^a-zA-Z0-9\-\_]/', '', lcfirst(ucwords(strtolower($this->label)))); } } diff --git a/src/Inachis/Common/Form/Fields/SelectOptionType.php b/src/Inachis/Common/Form/Fields/SelectOptionType.php index 90b12da6..943c9b28 100644 --- a/src/Inachis/Common/Form/Fields/SelectOptionType.php +++ b/src/Inachis/Common/Form/Fields/SelectOptionType.php @@ -3,6 +3,7 @@ namespace Inachis\Component\Common\Form\Fields; use Inachis\Component\Common\Form\FormComponent; + /** * Object for handling select fields */ diff --git a/src/Inachis/Common/Form/Fields/SelectType.php b/src/Inachis/Common/Form/Fields/SelectType.php index 9e1705ed..8e025991 100644 --- a/src/Inachis/Common/Form/Fields/SelectType.php +++ b/src/Inachis/Common/Form/Fields/SelectType.php @@ -3,6 +3,7 @@ namespace Inachis\Component\Common\Form\Fields; use Inachis\Component\Common\Form\FormComponent; + /** * Object for handling select fields */ diff --git a/src/Inachis/Common/Form/Fields/TextAreaType.php b/src/Inachis/Common/Form/Fields/TextAreaType.php index 8efa25d8..49de640a 100644 --- a/src/Inachis/Common/Form/Fields/TextAreaType.php +++ b/src/Inachis/Common/Form/Fields/TextAreaType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling textarea fields */ diff --git a/src/Inachis/Common/Form/Fields/TextType.php b/src/Inachis/Common/Form/Fields/TextType.php index 39aa621e..f1c01fe6 100644 --- a/src/Inachis/Common/Form/Fields/TextType.php +++ b/src/Inachis/Common/Form/Fields/TextType.php @@ -4,6 +4,7 @@ use Inachis\Component\Common\Form\FormComponent; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * Object for handling `type="text"` fields */ diff --git a/src/Inachis/Common/Form/FormBuilder.php b/src/Inachis/Common/Form/FormBuilder.php index c7622b5d..65161972 100644 --- a/src/Inachis/Common/Form/FormBuilder.php +++ b/src/Inachis/Common/Form/FormBuilder.php @@ -9,51 +9,51 @@ */ class FormBuilder extends AbstractFormType { - /** - * @var string[] The accepted HTTP/1.1 request methods - */ - private $allowedMethods = array( - 'DELETE', - 'GET', - 'POST', - 'PUT' - ); - /** - * @var string[] The allowed enctype values for the form - */ - private $allowedEncTypes = array( - 'application/x-www-form-urlencoded', - 'multipart/form-data', - 'text/plain' - ); - /** - * @var string The method to use for the form - */ - protected $method = 'POST'; - /** - * @var string The action for the form - */ - protected $action; - /** - * @var bool Flag indicating of the form - */ - protected $autoComplete = true; - /** - * @var string The enctype for the form - */ - protected $encType = 'text/plain'; - /** - * @var bool Flag indicating of validation should be disabled - */ - protected $noValidate = false; - /** - * @var FormComponent[] The array of components for the form - */ - protected $components = array(); - /** - * @var mixed[] The values for components in the form - */ - protected $data = array(); + /** + * @var string[] The accepted HTTP/1.1 request methods + */ + private $allowedMethods = array( + 'DELETE', + 'GET', + 'POST', + 'PUT' + ); + /** + * @var string[] The allowed enctype values for the form + */ + private $allowedEncTypes = array( + 'application/x-www-form-urlencoded', + 'multipart/form-data', + 'text/plain' + ); + /** + * @var string The method to use for the form + */ + protected $method = 'POST'; + /** + * @var string The action for the form + */ + protected $action; + /** + * @var bool Flag indicating of the form + */ + protected $autoComplete = true; + /** + * @var string The enctype for the form + */ + protected $encType = 'text/plain'; + /** + * @var bool Flag indicating of validation should be disabled + */ + protected $noValidate = false; + /** + * @var FormComponent[] The array of components for the form + */ + protected $components = array(); + /** + * @var mixed[] The values for components in the form + */ + protected $data = array(); /** * Default constructor for {@link FormBuilder} * @param string $action The URL to submit the form to @@ -62,9 +62,9 @@ class FormBuilder extends AbstractFormType */ public function __construct($action, $method = 'POST', $name = '') { - $this->setAction($action); - $this->setMethod($method); - $this->setName($name); + $this->setAction($action); + $this->setMethod($method); + $this->setName($name); } /** * Returns the type of the form element - in this case it will always be "form" @@ -72,7 +72,7 @@ public function __construct($action, $method = 'POST', $name = '') */ public function getType() { - return 'form'; + return 'form'; } /** * Sets the method the form should use @@ -81,14 +81,14 @@ public function getType() */ public function setMethod($value) { - $value = strtoupper($value); - if (!in_array($value, $this->allowedMethods)) { - throw new FormBuilderConfigurationException( - sprintf('Invalid method %s - allowed methods are: %s', $value, implode(', ', $this->allowedMethods)) - ); - } - $this->method = $value; - return $this; + $value = strtoupper($value); + if (!in_array($value, $this->allowedMethods)) { + throw new FormBuilderConfigurationException( + sprintf('Invalid method %s - allowed methods are: %s', $value, implode(', ', $this->allowedMethods)) + ); + } + $this->method = $value; + return $this; } /** * Sets the action the form should use @@ -97,11 +97,11 @@ public function setMethod($value) */ public function setAction($value) { - if (!is_string($value)) { - throw new FormBuilderConfigurationException(sprintf('Invalid action provided: %s', $value)); - } - $this->action = $value; - return $this; + if (!is_string($value)) { + throw new FormBuilderConfigurationException(sprintf('Invalid action provided: %s', $value)); + } + $this->action = $value; + return $this; } /** * Specifies if teh form should allow autocompletion of fields @@ -110,8 +110,8 @@ public function setAction($value) */ public function setAutoComplete($autocomplete) { - $this->autoComplete = (bool) $autocomplete; - return $this; + $this->autoComplete = (bool) $autocomplete; + return $this; } /** * Sets the enctype the form should use @@ -120,12 +120,12 @@ public function setAutoComplete($autocomplete) */ public function setEncType($enctype) { - $enctype = strtolower($enctype); - if (!in_array($enctype, $this->allowedEncTypes)) { - throw new FormBuilderConfigurationException(sprintf('%s is not a valid enctype', $enctype)); - } - $this->encType = $enctype; - return $this; + $enctype = strtolower($enctype); + if (!in_array($enctype, $this->allowedEncTypes)) { + throw new FormBuilderConfigurationException(sprintf('%s is not a valid enctype', $enctype)); + } + $this->encType = $enctype; + return $this; } /** * Specifies whether the form should use valdiation @@ -134,11 +134,11 @@ public function setEncType($enctype) */ public function setNoValidate($value) { - if (!is_bool($value)) { - throw new FormBuilderConfigurationException('novalidate MUST be boolean true or false'); - } - $this->noValidate = (bool) $value; - return $this; + if (!is_bool($value)) { + throw new FormBuilderConfigurationException('novalidate MUST be boolean true or false'); + } + $this->noValidate = (bool) $value; + return $this; } /** * Returns the method for the form @@ -146,7 +146,7 @@ public function setNoValidate($value) */ public function getMethod() { - return $this->method; + return $this->method; } /** * Returns the action for the form @@ -154,7 +154,7 @@ public function getMethod() */ public function getAction() { - return $this->action; + return $this->action; } /** * Returns the value of the flag indicating of autocomplete is enabled @@ -162,7 +162,7 @@ public function getAction() */ public function getAutoComplete() { - return $this->autoComplete; + return $this->autoComplete; } /** * Returns the enctype the form will use @@ -170,7 +170,7 @@ public function getAutoComplete() */ public function getEncType() { - return $this->encType; + return $this->encType; } /** * Returns the value of the flag indicating of validation is disabled @@ -178,7 +178,7 @@ public function getEncType() */ public function getNoValidate() { - return $this->noValidate; + return $this->noValidate; } /** * Returns the array of components for the form @@ -186,7 +186,7 @@ public function getNoValidate() */ public function getComponents() { - return $this->components; + return $this->components; } /** * Adds a new component to the form @@ -195,7 +195,7 @@ public function getComponents() */ public function addComponent(FormComponent $component) { - $this->components[$component->getName()] = $component; - return $this; + $this->components[$component->getName()] = $component; + return $this; } } diff --git a/src/Inachis/Common/Form/FormComponent.php b/src/Inachis/Common/Form/FormComponent.php index 7d9f6050..78fcec36 100644 --- a/src/Inachis/Common/Form/FormComponent.php +++ b/src/Inachis/Common/Form/FormComponent.php @@ -3,192 +3,193 @@ namespace Inachis\Component\Common\Form; use Inachis\Component\Common\Exception\FormBuilderConfigurationException; + /** * */ abstract class FormComponent extends AbstractFormType { - /** - * @var string The label for the form component - */ - protected $label; - /** - * @var string The value for the element - */ - protected $value; - /** - * @var bool Flag indicating if it should allow user-input - */ - protected $readOnly = false; - /** - * @var bool Flag indicating if the field is required - */ - protected $required = false; - /** - * @var bool Flag indicating if the field is disabled - */ - protected $disabled = false; - /** - * @var string HTML element to wrap the field in if set - */ - protected $wrapperElement = 'p'; - /** - * @var string[] The CSS classes to apply to the wrapping elements if applicable - */ - protected $wrapperClasses = array(); - /** - * Default constructor for {@link FormComponent} - * @param string $name The name of the form component - * @param string $label The label for the form component - * @param string $value The value for the form component - * @param string $id The ID of the form component - */ - public function __construct($name = '', $label = '', $value = '', $id = '') - { - $this->setName($name); - $this->setLabel($label); - $this->setValue($value); - $this->setId(!empty($id) ? $id : $name); - } - /** - * Sets the value of {@link $label} - * @param string $value The text to use for the label - * @return FormComponent Returns a reference to itself - */ - public function setLabel($value) - { - $this->label = $value; + /** + * @var string The label for the form component + */ + protected $label; + /** + * @var string The value for the element + */ + protected $value; + /** + * @var bool Flag indicating if it should allow user-input + */ + protected $readOnly = false; + /** + * @var bool Flag indicating if the field is required + */ + protected $required = false; + /** + * @var bool Flag indicating if the field is disabled + */ + protected $disabled = false; + /** + * @var string HTML element to wrap the field in if set + */ + protected $wrapperElement = 'p'; + /** + * @var string[] The CSS classes to apply to the wrapping elements if applicable + */ + protected $wrapperClasses = array(); + /** + * Default constructor for {@link FormComponent} + * @param string $name The name of the form component + * @param string $label The label for the form component + * @param string $value The value for the form component + * @param string $id The ID of the form component + */ + public function __construct($name = '', $label = '', $value = '', $id = '') + { + $this->setName($name); + $this->setLabel($label); + $this->setValue($value); + $this->setId(!empty($id) ? $id : $name); + } + /** + * Sets the value of {@link $label} + * @param string $value The text to use for the label + * @return FormComponent Returns a reference to itself + */ + public function setLabel($value) + { + $this->label = $value; + return $this; + } + /** + * Returns the value of {@link label} + * @return string The value of the property + */ + public function getLabel() + { + return $this->label; + } + /** + * Sets the value of {@link $value} + * @param string $value The value for the form element + * @return FormComponent Returns a reference to itself + */ + public function setValue($value) + { + $this->value = $value; + return $this; + } + /** + * Returns the value of {@link value} + * @return string The value of the property + */ + public function getValue() + { + return $this->value; + } + /** + * Sets the value of {@link $readOnly} + * @param bool $value The value to set the property to + * @return FormComponent Returns a reference to itself + */ + public function setReadOnly($value) + { + $this->readOnly = (bool) $value; return $this; - } - /** - * Returns the value of {@link label} - * @return string The value of the property - */ - public function getLabel() - { - return $this->label; - } - /** - * Sets the value of {@link $value} - * @param string $value The value for the form element - * @return FormComponent Returns a reference to itself - */ - public function setValue($value) - { - $this->value = $value; + } + /** + * Returns the value of {@link readOnly} + * @return bool The value of the property + */ + public function getReadOnly() + { + return $this->readOnly; + } + /** + * Sets the value of {@link $required} + * @param bool $value The value to set the property to + * @return FormComponent Returns a reference to itself + */ + public function setRequired($value) + { + $this->required = (bool) $value; return $this; - } - /** - * Returns the value of {@link value} - * @return string The value of the property - */ - public function getValue() - { - return $this->value; - } - /** - * Sets the value of {@link $readOnly} - * @param bool $value The value to set the property to - * @return FormComponent Returns a reference to itself - */ - public function setReadOnly($value) - { - $this->readOnly = (bool) $value; + } + /** + * Returns the value of {@link required} + * @return bool The value of the property + */ + public function getRequired() + { + return $this->required; + } + /** + * Sets the value of {@link $disabled} + * @param bool $value The value to set the property to + * @return FormComponent Returns a reference to itself + */ + public function setDisabled($value) + { + $this->disabled = (bool) $value; return $this; - } - /** - * Returns the value of {@link readOnly} - * @return bool The value of the property - */ - public function getReadOnly() - { - return $this->readOnly; - } - /** - * Sets the value of {@link $required} - * @param bool $value The value to set the property to - * @return FormComponent Returns a reference to itself - */ - public function setRequired($value) - { - $this->required = (bool) $value; + } + /** + * Returns the value of {@link disabled} + * @return bool The value of the property + */ + public function getDisabled() + { + return $this->disabled; + } + /** + * Sets the value of {@link $wrapperElement} + * @param string $value The value to set the property to + * @return FormComponent Returns a reference to itself + */ + public function setWrapperElement($value) + { + $this->wrapperElement = $value; + } + /** + * Returns the value of {@link wrapperElement} + * @return string The value of the property + */ + public function getWrapperElement() + { + return $this->wrapperElement; + } + /** + * Sets the value of {@link $wrapperClasses} + * @param string[] $value The value to set the property to + * @return FormComponent Returns a reference to itself + */ + public function setWrapperClasses($value) + { + if ($this->wrapperElement === '') { + throw new FormBuilderConfigurationException('Cannot apply wrapping CSS with no wrapper element'); + } + $this->wrapperClasses = $value; return $this; - } - /** - * Returns the value of {@link required} - * @return bool The value of the property - */ - public function getRequired() - { - return $this->required; - } - /** - * Sets the value of {@link $disabled} - * @param bool $value The value to set the property to - * @return FormComponent Returns a reference to itself - */ - public function setDisabled($value) - { - $this->disabled = (bool) $value; + } + /** + * Returns the value of {@link wrapperClasses} + * @return string[] The value of the property + */ + public function getWrapperClasses() + { + return $this->wrapperClasses; + } + /** + * Adds a value to {@link $wrapperClasses} + * @param string $value The CSS class to add + * @return FormComponent Returns a reference to itself + */ + public function addWrapperClass($value) + { + if ($this->wrapperElement === '') { + throw new FormBuilderConfigurationException('Cannot apply wrapping CSS with no wrapper element'); + } + $this->wrapperClasses[] = $value; return $this; - } - /** - * Returns the value of {@link disabled} - * @return bool The value of the property - */ - public function getDisabled() - { - return $this->disabled; - } - /** - * Sets the value of {@link $wrapperElement} - * @param string $value The value to set the property to - * @return FormComponent Returns a reference to itself - */ - public function setWrapperElement($value) - { - $this->wrapperElement = $value; - } - /** - * Returns the value of {@link wrapperElement} - * @return string The value of the property - */ - public function getWrapperElement() - { - return $this->wrapperElement; - } - /** - * Sets the value of {@link $wrapperClasses} - * @param string[] $value The value to set the property to - * @return FormComponent Returns a reference to itself - */ - public function setWrapperClasses($value) - { - if ($this->wrapperElement === '') { - throw new FormBuilderConfigurationException('Cannot apply wrapping CSS with no wrapper element'); - } - $this->wrapperClasses = $value; - return $this; - } - /** - * Returns the value of {@link wrapperClasses} - * @return string[] The value of the property - */ - public function getWrapperClasses() - { - return $this->wrapperClasses; - } - /** - * Adds a value to {@link $wrapperClasses} - * @param string $value The CSS class to add - * @return FormComponent Returns a reference to itself - */ - public function addWrapperClass($value) - { - if ($this->wrapperElement === '') { - throw new FormBuilderConfigurationException('Cannot apply wrapping CSS with no wrapper element'); - } - $this->wrapperClasses[] = $value; - return $this; - } + } } diff --git a/src/Inachis/Common/Form/FormComponentInterface.php b/src/Inachis/Common/Form/FormComponentInterface.php index 6a341782..68506aee 100644 --- a/src/Inachis/Common/Form/FormComponentInterface.php +++ b/src/Inachis/Common/Form/FormComponentInterface.php @@ -4,25 +4,25 @@ interface FormComponentInterface { - public static function getType(); + public static function getType(); - public static function setId($value); - public static function getId(); + public static function setId($value); + public static function getId(); - public static function setName($value); - public static function getName(); + public static function setName($value); + public static function getName(); - public static function setLabel($value); - public static function getLabel(); + public static function setLabel($value); + public static function getLabel(); - public static function setValue($value); - public static function getValue(); + public static function setValue($value); + public static function getValue(); - public static function setReadOnly($value); - public static function getReadOnly(); + public static function setReadOnly($value); + public static function getReadOnly(); - public static function setRequired($value); - public static function getRequired(); + public static function setRequired($value); + public static function getRequired(); - public static function build(); -} \ No newline at end of file + public static function build(); +}