@@ -25,8 +25,8 @@ discard block  | 
                                                    ||
| 25 | 25 | 'required' => false,  | 
                                                        
| 26 | 26 | 'readonly' => false,  | 
                                                        
| 27 | 27 | 'default' => null,  | 
                                                        
| 28 | - 'filter' => array( $this, 'filter' ),  | 
                                                        |
| 29 | - 'validation' => array( $this, 'validation' )  | 
                                                        |
| 28 | + 'filter' => array($this, 'filter'),  | 
                                                        |
| 29 | + 'validation' => array($this, 'validation')  | 
                                                        |
| 30 | 30 | );  | 
                                                        
| 31 | 31 | }  | 
                                                        
| 32 | 32 | |
@@ -35,14 +35,14 @@ discard block  | 
                                                    ||
| 35 | 35 | return floatval($v);  | 
                                                        
| 36 | 36 | }  | 
                                                        
| 37 | 37 | |
| 38 | - public function validation($v,&$e)  | 
                                                        |
| 38 | + public function validation($v, &$e)  | 
                                                        |
| 39 | 39 |      { | 
                                                        
| 40 | - if($v > $this->max)  | 
                                                        |
| 40 | + if ($v > $this->max)  | 
                                                        |
| 41 | 41 |          { | 
                                                        
| 42 | 42 |              $e = "must be less than {$this->max}"; | 
                                                        
| 43 | 43 | }  | 
                                                        
| 44 | 44 | |
| 45 | - if($v < $this->min)  | 
                                                        |
| 45 | + if ($v < $this->min)  | 
                                                        |
| 46 | 46 |          { | 
                                                        
| 47 | 47 |              $e = "must be greater than {$this->min}"; | 
                                                        
| 48 | 48 | }  | 
                                                        
@@ -59,12 +59,12 @@ discard block  | 
                                                    ||
| 59 | 59 | *  | 
                                                        
| 60 | 60 | * @param array $components An array of arrays of component arguments  | 
                                                        
| 61 | 61 | */  | 
                                                        
| 62 | - public function __construct( array $components = array() )  | 
                                                        |
| 62 | + public function __construct(array $components = array())  | 
                                                        |
| 63 | 63 |      { | 
                                                        
| 64 | - foreach( $components as $args )  | 
                                                        |
| 64 | + foreach ($components as $args)  | 
                                                        |
| 65 | 65 |          { | 
                                                        
| 66 | 66 | $name = $args['name'];  | 
                                                        
| 67 | - if(array_key_exists($name, $components))  | 
                                                        |
| 67 | + if (array_key_exists($name, $components))  | 
                                                        |
| 68 | 68 |              { | 
                                                        
| 69 | 69 |                  throw new \RuntimeException("A component with the name <b>$name</b> has already been created"); | 
                                                        
| 70 | 70 | }  | 
                                                        
@@ -89,18 +89,18 @@ discard block  | 
                                                    ||
| 89 | 89 | *  | 
                                                        
| 90 | 90 | * @return array The updated values array.  | 
                                                        
| 91 | 91 | */  | 
                                                        
| 92 | - public function update( array $new_instance, array $old_instance = array() )  | 
                                                        |
| 92 | + public function update(array $new_instance, array $old_instance = array())  | 
                                                        |
| 93 | 93 |      { | 
                                                        
| 94 | - $this->old_instance = array_merge($this->get_defaults(),$old_instance);  | 
                                                        |
| 95 | - $this->new_instance = array_merge($this->old_instance,$new_instance);  | 
                                                        |
| 94 | + $this->old_instance = array_merge($this->get_defaults(), $old_instance);  | 
                                                        |
| 95 | + $this->new_instance = array_merge($this->old_instance, $new_instance);  | 
                                                        |
| 96 | 96 | $this->final_instance = $this->new_instance;  | 
                                                        
| 97 | 97 | |
| 98 | - foreach ( $this->components as $component )  | 
                                                        |
| 98 | + foreach ($this->components as $component)  | 
                                                        |
| 99 | 99 |          { | 
                                                        
| 100 | 100 | // Update individual fields, as well as the composite parent field.  | 
                                                        
| 101 | - if ( $component instanceof ValueComponentInterface )  | 
                                                        |
| 101 | + if ($component instanceof ValueComponentInterface)  | 
                                                        |
| 102 | 102 |              { | 
                                                        
| 103 | - $this->update_component( $component );  | 
                                                        |
| 103 | + $this->update_component($component);  | 
                                                        |
| 104 | 104 | }  | 
                                                        
| 105 | 105 | }  | 
                                                        
| 106 | 106 | |
@@ -114,7 +114,7 @@ discard block  | 
                                                    ||
| 114 | 114 | */  | 
                                                        
| 115 | 115 | public function reset()  | 
                                                        
| 116 | 116 |      { | 
                                                        
| 117 | - foreach( $this->components as $c )  | 
                                                        |
| 117 | + foreach ($this->components as $c)  | 
                                                        |
| 118 | 118 |          { | 
                                                        
| 119 | 119 | $c->value = $c->default;  | 
                                                        
| 120 | 120 | $this->final_instance[$c->name] = $c->default;  | 
                                                        
@@ -139,7 +139,7 @@ discard block  | 
                                                    ||
| 139 | 139 | * @param string $name  | 
                                                        
| 140 | 140 | * @return UI\AbstractComponent  | 
                                                        
| 141 | 141 | */  | 
                                                        
| 142 | - public function get_component( $name )  | 
                                                        |
| 142 | + public function get_component($name)  | 
                                                        |
| 143 | 143 |      { | 
                                                        
| 144 | 144 | return $this->components[$name];  | 
                                                        
| 145 | 145 | }  | 
                                                        
@@ -161,21 +161,21 @@ discard block  | 
                                                    ||
| 161 | 161 | *  | 
                                                        
| 162 | 162 | * @param ValueComponentInterface $component The component to validate.  | 
                                                        
| 163 | 163 | */  | 
                                                        
| 164 | - private function update_component( ValueComponentInterface $component )  | 
                                                        |
| 164 | + private function update_component(ValueComponentInterface $component)  | 
                                                        |
| 165 | 165 |      { | 
                                                        
| 166 | 166 | $component->value = $this->final_instance[$component->name];  | 
                                                        
| 167 | 167 | |
| 168 | 168 | // Skip if this field is disabled  | 
                                                        
| 169 | - if( $this->is_disabled($component) )  | 
                                                        |
| 169 | + if ($this->is_disabled($component))  | 
                                                        |
| 170 | 170 |          { | 
                                                        
| 171 | 171 | return;  | 
                                                        
| 172 | 172 | }  | 
                                                        
| 173 | 173 | |
| 174 | 174 | // Apply user-defined filter  | 
                                                        
| 175 | - $this->filter( $component );  | 
                                                        |
| 175 | + $this->filter($component);  | 
                                                        |
| 176 | 176 | |
| 177 | 177 | // Validate value  | 
                                                        
| 178 | - $this->validate( $component );  | 
                                                        |
| 178 | + $this->validate($component);  | 
                                                        |
| 179 | 179 | }  | 
                                                        
| 180 | 180 | |
| 181 | 181 | /**  | 
                                                        
@@ -184,7 +184,7 @@ discard block  | 
                                                    ||
| 184 | 184 | * @param UI\AbstractComponent $component  | 
                                                        
| 185 | 185 | * @return boolean  | 
                                                        
| 186 | 186 | */  | 
                                                        
| 187 | - private function is_disabled( $component )  | 
                                                        |
| 187 | + private function is_disabled($component)  | 
                                                        |
| 188 | 188 |      { | 
                                                        
| 189 | 189 | return  | 
                                                        
| 190 | 190 | $component instanceof DisableableComponentInterface &&  | 
                                                        
@@ -199,13 +199,13 @@ discard block  | 
                                                    ||
| 199 | 199 | *  | 
                                                        
| 200 | 200 | * @param UI\AbstractComponent $component  | 
                                                        
| 201 | 201 | */  | 
                                                        
| 202 | - private function filter( $component )  | 
                                                        |
| 202 | + private function filter($component)  | 
                                                        |
| 203 | 203 |      { | 
                                                        
| 204 | - if( $component instanceof FilterableComponentInterface )  | 
                                                        |
| 204 | + if ($component instanceof FilterableComponentInterface)  | 
                                                        |
| 205 | 205 |          { | 
                                                        
| 206 | 206 | $filter = $component->filter;  | 
                                                        
| 207 | 207 | |
| 208 | - if( is_callable( $filter ) )  | 
                                                        |
| 208 | + if (is_callable($filter))  | 
                                                        |
| 209 | 209 |              { | 
                                                        
| 210 | 210 | $component->value = \call_user_func_array($filter, array($this->final_instance[$component->name]));  | 
                                                        
| 211 | 211 | $this->final_instance[$component->name] = $component->value;  | 
                                                        
@@ -221,22 +221,22 @@ discard block  | 
                                                    ||
| 221 | 221 | *  | 
                                                        
| 222 | 222 | * @param UI\AbstractComponent $component The component to validate.  | 
                                                        
| 223 | 223 | */  | 
                                                        
| 224 | - private function validate( $component )  | 
                                                        |
| 224 | + private function validate($component)  | 
                                                        |
| 225 | 225 |      { | 
                                                        
| 226 | - if( !($component instanceof ValidatableComponentInterface) ) return;  | 
                                                        |
| 226 | + if (!($component instanceof ValidatableComponentInterface)) return;  | 
                                                        |
| 227 | 227 | |
| 228 | 228 | $name = $component->name;  | 
                                                        
| 229 | 229 | $validate = $component->validation;  | 
                                                        
| 230 | 230 | |
| 231 | 231 | $component->validity = $component::VALID;  | 
                                                        
| 232 | 232 | |
| 233 | - if(is_callable($validate))  | 
                                                        |
| 233 | + if (is_callable($validate))  | 
                                                        |
| 234 | 234 |          { | 
                                                        
| 235 | 235 | $error = '';  | 
                                                        
| 236 | 236 | $valid = \call_user_func_array($validate, array($this->final_instance[$name], &$error));  | 
                                                        
| 237 | 237 | |
| 238 | 238 | // Invalid input, use old instance or default value  | 
                                                        
| 239 | - if ( true !== $valid )  | 
                                                        |
| 239 | + if (true !== $valid)  | 
                                                        |
| 240 | 240 |              { | 
                                                        
| 241 | 241 | $this->errors[$name] = $error ? $error : ValidatableComponentInterface::DEFAULT_MESSAGE;  | 
                                                        
| 242 | 242 | $component->value = $this->old_instance[$name];  | 
                                                        
@@ -255,7 +255,7 @@ discard block  | 
                                                    ||
| 255 | 255 |      { | 
                                                        
| 256 | 256 | $defaults = array();  | 
                                                        
| 257 | 257 | |
| 258 | - foreach( $this->components as $component )  | 
                                                        |
| 258 | + foreach ($this->components as $component)  | 
                                                        |
| 259 | 259 |          { | 
                                                        
| 260 | 260 | $defaults[$component->name] = $component->default;  | 
                                                        
| 261 | 261 | }  |