Completed
Push — master ( c8219e...d46307 )
by Askupa
01:31
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 1 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/number/controller.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -27,8 +27,8 @@  discard block
 block discarded – undo
27 27
             'required'      => false,
28 28
             'readonly'      => false,
29 29
             'default'       => null,
30
-            'filter'        => array( $this, 'filter' ),
31
-            'validation'    => array( $this, 'validation' )
30
+            'filter'        => array($this, 'filter'),
31
+            'validation'    => array($this, 'validation')
32 32
         );
33 33
     }
34 34
     
@@ -37,19 +37,19 @@  discard block
 block discarded – undo
37 37
         return floatval($v);
38 38
     }
39 39
     
40
-    public function validation($v,&$e)
40
+    public function validation($v, &$e)
41 41
     {
42 42
         $max = $this->max;
43 43
         $min = $this->min;
44 44
         
45
-        if(null !== $max && $v > $max)
45
+        if (null !== $max && $v > $max)
46 46
         {
47
-            $e = sprintf( __("Value must be less than %d",'amarkal'), $max);
47
+            $e = sprintf(__("Value must be less than %d", 'amarkal'), $max);
48 48
         }
49 49
 
50
-        if(null !== $min && $v < $min) 
50
+        if (null !== $min && $v < $min) 
51 51
         {
52
-            $e = sprintf( __("Value must be greater than %d",'amarkal'), $min);
52
+            $e = sprintf(__("Value must be greater than %d", 'amarkal'), $min);
53 53
         }
54 54
 
55 55
         return $e ? false : true;
Please login to merge, or discard this patch.
components/slider/controller.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,13 +25,13 @@
 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
         );
30 30
     }
31 31
     
32 32
     public function required_arguments()
33 33
     {
34
-        return array('name','min','max');
34
+        return array('name', 'min', 'max');
35 35
     }
36 36
     
37 37
     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.
components/switch/controller.php 1 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
         );
26 26
     }
27 27
     
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public function filter($v)
48 48
     {
49
-        if($v !== 'on') return 'off';
49
+        if ($v !== 'on') return 'off';
50 50
         return 'on';
51 51
     }
52 52
 }
53 53
\ No newline at end of file
Please login to merge, or discard this patch.
components/composite/controller.php 1 patch
Spacing   +22 added lines, -22 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
         }
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
      */
92 92
     public function required_arguments()
93 93
     {
94
-        return array('name','components','template');
94
+        return array('name', 'components', 'template');
95 95
     }
96 96
     
97 97
     /**
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
      */
110 110
     public function parse_template()
111 111
     {
112
-        return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a){
112
+        return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a) {
113 113
             $component = $this->get_component($a[1]);
114 114
             return $component->render();
115 115
         }, $this->model['template']);
@@ -124,7 +124,7 @@  discard block
 block discarded – undo
124 124
      */
125 125
     public function get_name()
126 126
     {
127
-        if('' !== $this->parent_name)
127
+        if ('' !== $this->parent_name)
128 128
         {
129 129
             return "{$this->parent_name}[{$this->name}]";
130 130
         }
@@ -133,9 +133,9 @@  discard block
 block discarded – undo
133 133
 
134 134
     public function filter($v)
135 135
     {
136
-        foreach($this->components as $component)
136
+        foreach ($this->components as $component)
137 137
         {
138
-            if($component instanceof FilterableComponentInterface &&
138
+            if ($component instanceof FilterableComponentInterface &&
139 139
                \is_callable($component->filter))
140 140
             {
141 141
                 $n = $component->name;
@@ -146,15 +146,15 @@  discard block
 block discarded – undo
146 146
         return $v;
147 147
     }
148 148
 
149
-    public function validation($v,&$e)
149
+    public function validation($v, &$e)
150 150
     {
151
-        foreach($this->components as $component)
151
+        foreach ($this->components as $component)
152 152
         {
153
-            if($component instanceof ValidatableComponentInterface &&
153
+            if ($component instanceof ValidatableComponentInterface &&
154 154
                \is_callable($component->validation))
155 155
             {
156 156
                 $n = $component->name;
157
-                if(!$component->validation($v[$n],$e))
157
+                if (!$component->validation($v[$n], $e))
158 158
                 {
159 159
                     return false;
160 160
                 }
@@ -168,7 +168,7 @@  discard block
 block discarded – undo
168 168
      */
169 169
     protected function on_created()
170 170
     {
171
-        foreach( $this->model['components'] as $args )
171
+        foreach ($this->model['components'] as $args)
172 172
         {
173 173
             $this->components[$args['name']] = $this->create_component($args);
174 174
         }
@@ -179,16 +179,16 @@  discard block
 block discarded – undo
179 179
      * @param type $args
180 180
      * @return type
181 181
      */
182
-    private function create_component( $args )
182
+    private function create_component($args)
183 183
     {
184 184
         $type = $args['type'];
185 185
         
186
-        if('composite' === $type)
186
+        if ('composite' === $type)
187 187
         {
188 188
             $args['parent_name'] = $this->get_name();
189 189
         }
190 190
         
191
-        $c = \Amarkal\UI\ComponentFactory::create( $type, $args );
191
+        $c = \Amarkal\UI\ComponentFactory::create($type, $args);
192 192
         
193 193
         // Apply the composite name template
194 194
         $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template);
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
      * @return UI\AbstractComponent
204 204
      * @throws \RuntimeException If there's no child component corresponding to the given name
205 205
      */
206
-    private function get_component( $name )
206
+    private function get_component($name)
207 207
     {
208
-        if(!array_key_exists($name, $this->components))
208
+        if (!array_key_exists($name, $this->components))
209 209
         {
210 210
             throw new \RuntimeException("Composite sub-component not found with name $name");
211 211
         }
Please login to merge, or discard this patch.