Completed
Push — master ( c8219e...d46307 )
by Askupa
01:31
created
components/code/controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@
 block discarded – undo
32 32
     
33 33
     public function required_arguments()
34 34
     {
35
-        return array('name','language');
35
+        return array('name', 'language');
36 36
     }
37 37
     
38 38
     public function get_template_path() 
Please login to merge, or discard this patch.
components/progressbar/controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
     
22 22
     public function required_arguments()
23 23
     {
24
-        return array('value','min','max');
24
+        return array('value', 'min', 'max');
25 25
     }
26 26
     
27 27
     public function get_template_path() 
Please login to merge, or discard this patch.
ComponentList.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
      *
20 20
      * @param array $components
21 21
      */
22
-    public function __construct( array $components = array() )
22
+    public function __construct(array $components = array())
23 23
     {
24 24
         $this->add_components($components);
25 25
     }
@@ -30,12 +30,12 @@  discard block
 block discarded – undo
30 30
      * @param string $name
31 31
      * @return AbstractComponent
32 32
      */
33
-    public function get_by_name( $name )
33
+    public function get_by_name($name)
34 34
     {
35 35
         $filtered = $this->filter(function($c) use ($name) {
36 36
             return $c instanceof ValueComponentInterface && $c->name === $name;
37 37
         });
38
-        if(count($filtered) < 1)
38
+        if (count($filtered) < 1)
39 39
         {
40 40
             throw new \RuntimeException("No component with the name <b>$name</b> could be found.");
41 41
         }
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param string $type
49 49
      * @return AbstractComponent[]
50 50
      */
51
-    public function get_by_type( $type )
51
+    public function get_by_type($type)
52 52
     {
53 53
         return $this->filter(function($c) use ($type) {
54 54
             return $c->component_type === $type;
@@ -107,9 +107,9 @@  discard block
 block discarded – undo
107 107
      * @param AbstractComponent[] $components
108 108
      * @return void
109 109
      */
110
-    public function add_components( array $components )
110
+    public function add_components(array $components)
111 111
     {
112
-        foreach( $components as $component )
112
+        foreach ($components as $component)
113 113
         {
114 114
             $this->add_component($component);
115 115
         }
@@ -121,9 +121,9 @@  discard block
 block discarded – undo
121 121
      * @param AbstractComponent[] $args
122 122
      * @return void
123 123
      */
124
-    public function add_component( array $args )
124
+    public function add_component(array $args)
125 125
     {
126
-        if(!array_key_exists('type', $args))
126
+        if (!array_key_exists('type', $args))
127 127
         {
128 128
             throw new \RuntimeException("Component configuration arrays must have a <b>type</b> argument");
129 129
         }
@@ -140,16 +140,16 @@  discard block
 block discarded – undo
140 140
      * @param AbstractComponent $comp
141 141
      * @return void
142 142
      */
143
-    private function verify_name_uniqueness( AbstractComponent $comp )
143
+    private function verify_name_uniqueness(AbstractComponent $comp)
144 144
     {
145
-        if(!($comp instanceof ValueComponentInterface))
145
+        if (!($comp instanceof ValueComponentInterface))
146 146
         {
147 147
             return;
148 148
         }
149 149
 
150 150
         foreach ($this->components as $c) 
151 151
         {
152
-            if($c->name === $comp->name)
152
+            if ($c->name === $comp->name)
153 153
             {
154 154
                 throw new \RuntimeException("Duplicate component name detected for the name <b>{$c->name}</b>.");
155 155
             }
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
      * @param function $callable
163 163
      * @return array
164 164
      */
165
-    private function filter( $callable )
165
+    private function filter($callable)
166 166
     {
167 167
         // array_values is needed in order to reindex the array after filtering it
168 168
         return array_values(array_filter($this->components, $callable));
Please login to merge, or discard this patch.
Form.php 1 patch
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -59,9 +59,9 @@  discard block
 block discarded – undo
59 59
      * 
60 60
      * @param ComponentList $component_list
61 61
      */
62
-    public function __construct( ComponentList $component_list = null )
62
+    public function __construct(ComponentList $component_list = null)
63 63
     {
64
-        if(null === $component_list)
64
+        if (null === $component_list)
65 65
         {
66 66
             $component_list = new ComponentList();
67 67
         }
@@ -85,16 +85,16 @@  discard block
 block discarded – undo
85 85
      * 
86 86
      * @return array The updated values array.
87 87
      */
88
-    public function update( array $new_instance = array(), array $old_instance = array() )
88
+    public function update(array $new_instance = array(), array $old_instance = array())
89 89
     {
90
-        $this->old_instance   = array_merge($this->get_defaults(),$old_instance);
91
-        $this->new_instance   = array_merge($this->old_instance,$new_instance);
90
+        $this->old_instance   = array_merge($this->get_defaults(), $old_instance);
91
+        $this->new_instance   = array_merge($this->old_instance, $new_instance);
92 92
         $this->final_instance = $this->new_instance;
93 93
         
94
-        foreach ( $this->component_list->get_value_components() as $component ) 
94
+        foreach ($this->component_list->get_value_components() as $component) 
95 95
         {
96 96
             // Update individual fields, as well as the composite parent field.
97
-            $this->update_component( $component );
97
+            $this->update_component($component);
98 98
         }
99 99
         
100 100
         return $this->final_instance;
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
      * @param array $components
119 119
      * @return void
120 120
      */
121
-    public function reset_components( array $components )
121
+    public function reset_components(array $components)
122 122
     {
123
-        foreach( $components as $component )
123
+        foreach ($components as $component)
124 124
         {
125 125
             $this->reset_component($component);
126 126
         }
@@ -133,7 +133,7 @@  discard block
 block discarded – undo
133 133
      * @param AbstractComponent $component
134 134
      * @return void
135 135
      */
136
-    public function reset_component( $component )
136
+    public function reset_component($component)
137 137
     {
138 138
         $component->value = $component->default;
139 139
         $this->final_instance[$component->name] = $component->default;
@@ -168,21 +168,21 @@  discard block
 block discarded – undo
168 168
      * 
169 169
      * @param ValueComponentInterface $component The component to validate.
170 170
      */
171
-    private function update_component( ValueComponentInterface $component )
171
+    private function update_component(ValueComponentInterface $component)
172 172
     {
173 173
         $component->value = $this->final_instance[$component->name];
174 174
         
175 175
         // Skip if this field is disabled
176
-        if( $this->is_disabled($component) )
176
+        if ($this->is_disabled($component))
177 177
         {
178 178
             return;
179 179
         }
180 180
 
181 181
         // Apply user-defined filter
182
-        $this->filter( $component );
182
+        $this->filter($component);
183 183
         
184 184
         // Validate value
185
-        $this->validate( $component );
185
+        $this->validate($component);
186 186
     }
187 187
     
188 188
     /**
@@ -191,7 +191,7 @@  discard block
 block discarded – undo
191 191
      * @param UI\AbstractComponent $component
192 192
      * @return boolean
193 193
      */
194
-    private function is_disabled( $component )
194
+    private function is_disabled($component)
195 195
     {
196 196
         return 
197 197
             $component instanceof DisableableComponentInterface &&
@@ -206,13 +206,13 @@  discard block
 block discarded – undo
206 206
      * 
207 207
      * @param UI\AbstractComponent $component
208 208
      */
209
-    private function filter( $component )
209
+    private function filter($component)
210 210
     {
211
-        if( $component instanceof FilterableComponentInterface )
211
+        if ($component instanceof FilterableComponentInterface)
212 212
         {
213 213
             $filter = $component->filter;
214 214
 
215
-            if( is_callable( $filter ) ) 
215
+            if (is_callable($filter)) 
216 216
             {
217 217
                 $component->value = \call_user_func_array($filter, array($this->final_instance[$component->name]));
218 218
                 $this->final_instance[$component->name] = $component->value;
@@ -228,22 +228,22 @@  discard block
 block discarded – undo
228 228
      * 
229 229
      * @param UI\AbstractComponent $component The component to validate.
230 230
      */
231
-    private function validate( $component )
231
+    private function validate($component)
232 232
     {
233
-        if( !($component instanceof ValidatableComponentInterface) ) return;
233
+        if (!($component instanceof ValidatableComponentInterface)) return;
234 234
         
235 235
         $name     = $component->name;
236 236
         $validate = $component->validation;
237 237
         
238 238
         $component->validity = $component::VALID;
239 239
         
240
-        if(is_callable($validate))
240
+        if (is_callable($validate))
241 241
         {
242 242
             $error = '';
243 243
             $valid = \call_user_func_array($validate, array($this->final_instance[$name], &$error));
244 244
             
245 245
             // Invalid input, use old instance or default value
246
-            if ( true !== $valid ) 
246
+            if (true !== $valid) 
247 247
             {
248 248
                 $this->errors[$name]         = $error ? $error : ValidatableComponentInterface::DEFAULT_MESSAGE;
249 249
                 $component->value            = $this->old_instance[$name];
@@ -262,7 +262,7 @@  discard block
 block discarded – undo
262 262
     {
263 263
         $defaults = array();
264 264
         
265
-        foreach( $this->component_list->get_value_components() as $component )
265
+        foreach ($this->component_list->get_value_components() as $component)
266 266
         {
267 267
             $defaults[$component->name] = $component->default;
268 268
         }
Please login to merge, or discard this patch.
Template.php 1 patch
Spacing   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -25,9 +25,9 @@  discard block
 block discarded – undo
25 25
      * @param array $model
26 26
      * @param string $template_path
27 27
      */
28
-    public function __construct( array $model = array(), $template_path = null ) 
28
+    public function __construct(array $model = array(), $template_path = null) 
29 29
     {
30
-        $this->set_model( $model );
30
+        $this->set_model($model);
31 31
         $this->template = $template_path;
32 32
     }
33 33
     
@@ -38,9 +38,9 @@  discard block
 block discarded – undo
38 38
      * 
39 39
      * @return mixed the argument's value.
40 40
      */
41
-    public function __get( $name ) 
41
+    public function __get($name) 
42 42
     {
43
-        if( isset( $this->model[$name] ) )
43
+        if (isset($this->model[$name]))
44 44
         {
45 45
             return $this->model[$name];
46 46
         }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
      * 
55 55
      * @return mixed the settings' argument value.
56 56
      */
57
-    public function __set( $name, $value )
57
+    public function __set($name, $value)
58 58
     {
59 59
         $this->model[$name] = $value;
60 60
     }
@@ -65,7 +65,7 @@  discard block
 block discarded – undo
65 65
      * @param string $name The argument's name.
66 66
      * @return boolean Whether this arguments exists or not.
67 67
      */
68
-    public function __isset( $name )
68
+    public function __isset($name)
69 69
     {
70 70
         return isset($this->model[$name]);
71 71
     }
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      * 
86 86
      * @return array
87 87
      */
88
-    public function set_model( $model )
88
+    public function set_model($model)
89 89
     {
90 90
         $this->model = $model;
91 91
     }
@@ -106,22 +106,22 @@  discard block
 block discarded – undo
106 106
      * @return string The rendered template.
107 107
      * @throws TemplateNotFoundException Thrown if the template file cannot be found.
108 108
      */
109
-    public function render( $echo = false )
109
+    public function render($echo = false)
110 110
     {
111 111
         $rendered_html = '';
112 112
         
113
-        if( file_exists( $this->get_template_path() ) ) 
113
+        if (file_exists($this->get_template_path())) 
114 114
         {
115 115
             ob_start();
116
-            include( $this->get_template_path() );
116
+            include($this->get_template_path());
117 117
             $rendered_html = ob_get_clean();
118 118
         } 
119 119
         else 
120 120
         {
121
-            throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_template_path() );
121
+            throw new \RuntimeException("Error: cannot render HTML, template file not found at ".$this->get_template_path());
122 122
         }
123 123
         
124
-        if( !$echo )
124
+        if (!$echo)
125 125
         {
126 126
             return $rendered_html;
127 127
         }
Please login to merge, or discard this patch.
components/toggle/controller.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,7 +15,7 @@  discard block
 block discarded – undo
15 15
     
16 16
     protected function on_created() 
17 17
     {
18
-        if($this->multi && !\is_array($this->default)
18
+        if ($this->multi && !\is_array($this->default)
19 19
         || !$this->multi && \is_array($this->default))
20 20
         {
21 21
             throw new \RuntimeException("The default value must be an array if multi is set to true, and must be a string otherwise.");
@@ -33,13 +33,13 @@  discard block
 block discarded – undo
33 33
             'multi'         => false,
34 34
             'data'          => array(),
35 35
             'default'       => array(),
36
-            'filter'        => array( $this, 'filter' )
36
+            'filter'        => array($this, 'filter')
37 37
         );
38 38
     }
39 39
     
40 40
     public function required_arguments()
41 41
     {
42
-        return array('name','data');
42
+        return array('name', 'data');
43 43
     }
44 44
     
45 45
     public function get_template_path() 
@@ -58,16 +58,16 @@  discard block
 block discarded – undo
58 58
      */
59 59
     public function filter($v)
60 60
     {
61
-        if($this->multi && !\is_array($v)) 
61
+        if ($this->multi && !\is_array($v)) 
62 62
         {
63 63
             return \explode(',', $v);
64 64
         }
65 65
         return $v;
66 66
     }
67 67
 
68
-    protected function is_selected( $value )
68
+    protected function is_selected($value)
69 69
     {
70
-        if($this->multi) 
70
+        if ($this->multi) 
71 71
         {
72 72
             return \in_array($value, $this->value);
73 73
         }
Please login to merge, or discard this patch.
AbstractComponent.php 1 patch
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
      * 
39 39
      * @param array $model
40 40
      */
41
-    public function __construct( array $model = array() ) 
41
+    public function __construct(array $model = array()) 
42 42
     {
43 43
         parent::__construct($model);
44 44
         
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             $this->component_type
48 48
         ));
49 49
 
50
-        if($this instanceof DisableableComponentInterface && $this->disabled)
50
+        if ($this instanceof DisableableComponentInterface && $this->disabled)
51 51
         {
52 52
             $this->add_html_class('amarkal-ui-disabled');
53 53
         }
@@ -84,24 +84,24 @@  discard block
 block discarded – undo
84 84
      * 
85 85
      * @return array
86 86
      */
87
-    public function set_model( $model )
87
+    public function set_model($model)
88 88
     {
89 89
         // Check that the required arguments are provided.
90
-        foreach( $this->required_arguments() as $key )
90
+        foreach ($this->required_arguments() as $key)
91 91
         {
92
-            if ( !isset($model[$key]) )
92
+            if (!isset($model[$key]))
93 93
             {
94 94
                 throw new \RuntimeException('The required argument "'.$key.'" was not provided for '.get_called_class());
95 95
             }
96 96
         }
97 97
         
98 98
         // Assign the name of the component as the id if no id was specified
99
-        if( !isset($model['id']) && isset($model['name']) )
99
+        if (!isset($model['id']) && isset($model['name']))
100 100
         {
101 101
             $model['id'] = $model['name'];
102 102
         }
103 103
         
104
-        $this->model = array_merge( $this->default_model(), $model );
104
+        $this->model = array_merge($this->default_model(), $model);
105 105
     }
106 106
     
107 107
     /**
@@ -120,9 +120,9 @@  discard block
 block discarded – undo
120 120
      * 
121 121
      * @param string $class
122 122
      */
123
-    public function add_html_class( $class )
123
+    public function add_html_class($class)
124 124
     {
125
-        if( !in_array($class, $this->html_classes) )
125
+        if (!in_array($class, $this->html_classes))
126 126
         {
127 127
             $this->html_classes[] = $class;
128 128
         }
@@ -134,14 +134,14 @@  discard block
 block discarded – undo
134 134
      * 
135 135
      * @param string $class
136 136
      */
137
-    public function remove_html_class( $class )
137
+    public function remove_html_class($class)
138 138
     {
139 139
         $i = 0;
140
-        foreach( $this->html_classes as $c )
140
+        foreach ($this->html_classes as $c)
141 141
         {
142
-            if( $c === $class )
142
+            if ($c === $class)
143 143
             {
144
-                array_splice($this->html_classes,$i,1);
144
+                array_splice($this->html_classes, $i, 1);
145 145
                 break;
146 146
             }
147 147
             $i++;
@@ -153,10 +153,10 @@  discard block
 block discarded – undo
153 153
      * 
154 154
      * @param type $validity
155 155
      */
156
-    Public function set_validity( $validity )
156
+    Public function set_validity($validity)
157 157
     {
158 158
         $this->validity = $validity;
159
-        if($validity === $this::INVALID)
159
+        if ($validity === $this::INVALID)
160 160
         {
161 161
             $this->add_html_class('amarkal-ui-component-error');
162 162
         }
@@ -179,7 +179,7 @@  discard block
 block discarded – undo
179 179
      * 
180 180
      * {@inheritdoc}
181 181
      */
182
-    public function render( $echo = false )
182
+    public function render($echo = false)
183 183
     {
184 184
         $this->enqueue_scripts();
185 185
         
@@ -187,7 +187,7 @@  discard block
 block discarded – undo
187 187
         include dirname(__FILE__).'/AbstractComponent.phtml';
188 188
         $html = ob_get_clean();
189 189
 
190
-        if( !$echo )
190
+        if (!$echo)
191 191
         {
192 192
             return $html;
193 193
         }
Please login to merge, or discard this patch.