Completed
Push — master ( b56cf6...b21678 )
by Askupa
01:23
created
components/select/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('name','data');
24
+        return array('name', 'data');
25 25
     }
26 26
     
27 27
     public function get_template_path() 
Please login to merge, or discard this patch.
composer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -6,7 +6,7 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 // Load module functions
12 12
 require_once 'functions.php';
13 13
\ No newline at end of file
Please login to merge, or discard this patch.
ComponentFactory.php 2 patches
Doc Comments   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -52,8 +52,8 @@  discard block
 block discarded – undo
52 52
     
53 53
     /**
54 54
      * 
55
-     * @param type $type
56
-     * @param type $props
55
+     * @param string $type
56
+     * @param type string
57 57
      * @throws \RuntimeException
58 58
      */
59 59
     private static function create_core_component( $type, $props )
@@ -79,8 +79,8 @@  discard block
 block discarded – undo
79 79
     
80 80
     /**
81 81
      * 
82
-     * @param type $type
83
-     * @param type $props
82
+     * @param string $type
83
+     * @param type string
84 84
      * @throws \RuntimeException
85 85
      */
86 86
     private static function create_registered_component( $type, $props )
Please login to merge, or discard this patch.
Spacing   +8 added lines, -8 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
      * @param array $props
21 21
      * @return AbstractComponent
22 22
      */
23
-    public static function create( $type, array $props )
23
+    public static function create($type, array $props)
24 24
     {
25 25
         try {
26 26
             $component = self::create_registered_component($type, $props);
@@ -41,9 +41,9 @@  discard block
 block discarded – undo
41 41
      * @param string $class_name
42 42
      * @throws \RuntimeException
43 43
      */
44
-    public static function register( $type, $class_name )
44
+    public static function register($type, $class_name)
45 45
     {
46
-        if( !in_array($type, self::$registered_components) )
46
+        if (!in_array($type, self::$registered_components))
47 47
         {
48 48
             self::$registered_components[$type] = $class_name;
49 49
         }
@@ -56,15 +56,15 @@  discard block
 block discarded – undo
56 56
      * @param type $props
57 57
      * @throws \RuntimeException
58 58
      */
59
-    private static function create_core_component( $type, $props )
59
+    private static function create_core_component($type, $props)
60 60
     {
61 61
         $file_name  = __DIR__."/components/$type/controller.php";
62 62
         $class_name = 'Amarkal\\UI\\Component_'.$type;
63 63
         
64 64
         // Load one of the core components
65
-        if(!class_exists($class_name))
65
+        if (!class_exists($class_name))
66 66
         {
67
-            if( file_exists( $file_name ) ) 
67
+            if (file_exists($file_name)) 
68 68
             {
69 69
                 require_once $file_name;
70 70
             }
@@ -83,9 +83,9 @@  discard block
 block discarded – undo
83 83
      * @param type $props
84 84
      * @throws \RuntimeException
85 85
      */
86
-    private static function create_registered_component( $type, $props )
86
+    private static function create_registered_component($type, $props)
87 87
     {
88
-        if(in_array($type, self::$registered_components))
88
+        if (in_array($type, self::$registered_components))
89 89
         {
90 90
             $class_name = self::$registered_components[$type];
91 91
             return new $class_name($props);
Please login to merge, or discard this patch.
bootstrap.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -6,13 +6,13 @@
 block discarded – undo
6 6
  */
7 7
 
8 8
 // Prevent direct file access
9
-defined( 'ABSPATH' ) or die( 'No script kiddies please!' );
9
+defined('ABSPATH') or die('No script kiddies please!');
10 10
 
11 11
 /**
12 12
  * Load module functions. If this amarkal module has not been loaded, 
13 13
  * functions.php will not return false.
14 14
  */
15
-if(false !== (require_once 'functions.php'))
15
+if (false !== (require_once 'functions.php'))
16 16
 {
17 17
     // Load required classes if not using composer
18 18
     require_once 'AbstractComponent.php';
Please login to merge, or discard this patch.
components/composite/controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -123,7 +123,7 @@
 block discarded – undo
123 123
     /**
124 124
      * 
125 125
      * @param type $args
126
-     * @return type
126
+     * @return AbstractComponent
127 127
      */
128 128
     private function create_component( $args )
129 129
     {
Please login to merge, or discard this patch.
Spacing   +21 added lines, -21 removed lines patch added patch discarded remove patch
@@ -25,16 +25,16 @@  discard block
 block discarded – undo
25 25
      * The __set magic method is overridden here to apply value & name changes to 
26 26
      * child components.
27 27
      */
28
-    public function __set( $name, $value )
28
+    public function __set($name, $value)
29 29
     {
30 30
         parent::__set($name, $value);
31 31
         
32
-        if( 'value' === $name )
32
+        if ('value' === $name)
33 33
         {
34 34
             $this->set_value($value);
35 35
         }
36 36
 
37
-        if( 'name' === $name )
37
+        if ('name' === $name)
38 38
         {
39 39
             $this->set_name($value);
40 40
         }
@@ -46,9 +46,9 @@  discard block
 block discarded – undo
46 46
      * @param array $value
47 47
      * @return void
48 48
      */
49
-    public function set_value( array $value )
49
+    public function set_value(array $value)
50 50
     {
51
-        foreach($value as $n => $v)
51
+        foreach ($value as $n => $v)
52 52
         {
53 53
             $component = $this->get_component($n);
54 54
             $component->value = $v;
@@ -61,9 +61,9 @@  discard block
 block discarded – undo
61 61
      * @param string $name
62 62
      * @return void
63 63
      */
64
-    public function set_name( $name )
64
+    public function set_name($name)
65 65
     {
66
-        foreach($this->components as $c)
66
+        foreach ($this->components as $c)
67 67
         {
68 68
             $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template);
69 69
         }
@@ -92,7 +92,7 @@  discard block
 block discarded – undo
92 92
      */
93 93
     public function required_arguments()
94 94
     {
95
-        return array('name','components','template');
95
+        return array('name', 'components', 'template');
96 96
     }
97 97
     
98 98
     /**
@@ -126,7 +126,7 @@  discard block
 block discarded – undo
126 126
      */
127 127
     public function get_name()
128 128
     {
129
-        if('' !== $this->parent_name)
129
+        if ('' !== $this->parent_name)
130 130
         {
131 131
             return "{$this->parent_name}[{$this->name}]";
132 132
         }
@@ -135,9 +135,9 @@  discard block
 block discarded – undo
135 135
 
136 136
     public function filter($v)
137 137
     {
138
-        foreach($this->components as $component)
138
+        foreach ($this->components as $component)
139 139
         {
140
-            if($component instanceof FilterableComponentInterface &&
140
+            if ($component instanceof FilterableComponentInterface &&
141 141
                \is_callable($component->filter))
142 142
             {
143 143
                 $n = $component->name;
@@ -148,15 +148,15 @@  discard block
 block discarded – undo
148 148
         return $v;
149 149
     }
150 150
 
151
-    public function validation($v,&$e)
151
+    public function validation($v, &$e)
152 152
     {
153
-        foreach($this->components as $component)
153
+        foreach ($this->components as $component)
154 154
         {
155
-            if($component instanceof ValidatableComponentInterface &&
155
+            if ($component instanceof ValidatableComponentInterface &&
156 156
                \is_callable($component->validation))
157 157
             {
158 158
                 $n = $component->name;
159
-                if(!$component->validation($v[$n],$e))
159
+                if (!$component->validation($v[$n], $e))
160 160
                 {
161 161
                     return false;
162 162
                 }
@@ -172,9 +172,9 @@  discard block
 block discarded – undo
172 172
      * @return UI\AbstractComponent
173 173
      * @throws \RuntimeException If there's no child component corresponding to the given name
174 174
      */
175
-    public function get_component( $name )
175
+    public function get_component($name)
176 176
     {
177
-        if(!array_key_exists($name, $this->components))
177
+        if (!array_key_exists($name, $this->components))
178 178
         {
179 179
             throw new \RuntimeException("Composite sub-component not found with name $name");
180 180
         }
@@ -186,7 +186,7 @@  discard block
 block discarded – undo
186 186
      */
187 187
     protected function on_created()
188 188
     {
189
-        foreach( $this->model['components'] as $args )
189
+        foreach ($this->model['components'] as $args)
190 190
         {
191 191
             $this->components[$args['name']] = $this->create_component($args);
192 192
         }
@@ -197,16 +197,16 @@  discard block
 block discarded – undo
197 197
      * @param type $args
198 198
      * @return type
199 199
      */
200
-    private function create_component( $args )
200
+    private function create_component($args)
201 201
     {
202 202
         $type = $args['type'];
203 203
         
204
-        if('composite' === $type)
204
+        if ('composite' === $type)
205 205
         {
206 206
             $args['parent_name'] = $this->get_name();
207 207
         }
208 208
         
209
-        $c = \Amarkal\UI\ComponentFactory::create( $type, $args );
209
+        $c = \Amarkal\UI\ComponentFactory::create($type, $args);
210 210
         
211 211
         // Apply the composite name template
212 212
         $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template);
Please login to merge, or discard this patch.
components/switch/controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@
 block discarded – undo
43 43
      * handle this.
44 44
      *
45 45
      * @param [string] $v
46
-     * @return void
46
+     * @return string
47 47
      */
48 48
     public function filter($v)
49 49
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@  discard block
 block discarded – undo
21 21
             'disabled'      => false,
22 22
             'readonly'      => false,
23 23
             'default'       => null,
24
-            'filter'        => array( $this, 'filter' ),
24
+            'filter'        => array($this, 'filter'),
25 25
             'show'          => null
26 26
         );
27 27
     }
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
      */
48 48
     public function filter($v)
49 49
     {
50
-        if($v !== 'on') return 'off';
50
+        if ($v !== 'on') return 'off';
51 51
         return 'on';
52 52
     }
53 53
 }
54 54
\ No newline at end of file
Please login to merge, or discard this patch.
components/slider/controller.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
      * will handle this.
46 46
      *
47 47
      * @param [string] $v
48
-     * @return void
48
+     * @return double
49 49
      */
50 50
     public function filter($v)
51 51
     {
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,14 +25,14 @@
 block discarded – undo
25 25
             'min'           => null,
26 26
             'max'           => null,
27 27
             'step'          => 1,
28
-            'filter'        => array( $this, 'filter' ),
28
+            'filter'        => array($this, 'filter'),
29 29
             'show'          => null
30 30
         );
31 31
     }
32 32
     
33 33
     public function required_arguments()
34 34
     {
35
-        return array('name','min','max');
35
+        return array('name', 'min', 'max');
36 36
     }
37 37
     
38 38
     public function get_template_path() 
Please login to merge, or discard this patch.
components/button/controller.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@
 block discarded – undo
29 29
     
30 30
     public function required_arguments()
31 31
     {
32
-        return array('request_url','label_start');
32
+        return array('request_url', 'label_start');
33 33
     }
34 34
     
35 35
     public function get_template_path() 
Please login to merge, or discard this patch.
ComponentList.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -159,7 +159,7 @@
 block discarded – undo
159 159
     /**
160 160
      * Filter the list of components
161 161
      *
162
-     * @param function $callable
162
+     * @param \Closure $callable
163 163
      * @return array
164 164
      */
165 165
     private function filter( $callable )
Please login to merge, or discard this 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.