Completed
Push — master ( 7deb80...a4d7e3 )
by Askupa
01:24
created
components/select/controller.php 2 patches
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.
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 class Component_select
9 9
 extends AbstractComponent
10 10
 implements ValueComponentInterface, 
11
-           DisableableComponentInterface
11
+            DisableableComponentInterface
12 12
 {
13 13
     public $component_type = 'select';
14 14
     
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.
Template.php 1 patch
Spacing   +11 added lines, -11 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
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
      * 
75 75
      * @return array
76 76
      */
77
-    public function set_model( $model )
77
+    public function set_model($model)
78 78
     {
79 79
         $this->model = $model;
80 80
     }
@@ -95,22 +95,22 @@  discard block
 block discarded – undo
95 95
      * @return string The rendered template.
96 96
      * @throws TemplateNotFoundException Thrown if the template file cannot be found.
97 97
      */
98
-    public function render( $echo = false )
98
+    public function render($echo = false)
99 99
     {
100 100
         $rendered_html = '';
101 101
         
102
-        if( file_exists( $this->get_template_path() ) ) 
102
+        if (file_exists($this->get_template_path())) 
103 103
         {
104 104
             ob_start();
105
-            include( $this->get_template_path() );
105
+            include($this->get_template_path());
106 106
             $rendered_html = ob_get_clean();
107 107
         } 
108 108
         else 
109 109
         {
110
-            throw new \RuntimeException( "Error: cannot render HTML, template file not found at " . $this->get_template_path() );
110
+            throw new \RuntimeException("Error: cannot render HTML, template file not found at ".$this->get_template_path());
111 111
         }
112 112
         
113
-        if( !$echo )
113
+        if (!$echo)
114 114
         {
115 115
             return $rendered_html;
116 116
         }
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/checkbox/controller.php 1 patch
Indentation   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -8,7 +8,7 @@
 block discarded – undo
8 8
 class Component_checkbox
9 9
 extends AbstractComponent
10 10
 implements ValueComponentInterface, 
11
-           DisableableComponentInterface
11
+            DisableableComponentInterface
12 12
 {
13 13
     public $name_template = '{{name}}[]';
14 14
     
Please login to merge, or discard this patch.
components/composite/controller.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 class Component_composite
9 9
 extends AbstractComponent
10 10
 implements ValueComponentInterface, 
11
-           DisableableComponentInterface,
12
-           FilterableComponentInterface,
13
-           ValidatableComponentInterface
11
+            DisableableComponentInterface,
12
+            FilterableComponentInterface,
13
+            ValidatableComponentInterface
14 14
 {
15 15
     /**
16 16
      * The list of child components.
Please login to merge, or discard this patch.
Spacing   +19 added lines, -19 removed lines patch added patch discarded remove patch
@@ -25,11 +25,11 @@  discard block
 block discarded – undo
25 25
      * The __set magic method is overridden here to apply value 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
         }
@@ -40,9 +40,9 @@  discard block
 block discarded – undo
40 40
      * 
41 41
      * @param array $value
42 42
      */
43
-    public function set_value( array $value )
43
+    public function set_value(array $value)
44 44
     {
45
-        foreach($value as $n => $v)
45
+        foreach ($value as $n => $v)
46 46
         {
47 47
             $component = $this->get_component($n);
48 48
             $component->value = $v;
@@ -71,7 +71,7 @@  discard block
 block discarded – undo
71 71
      */
72 72
     public function required_arguments()
73 73
     {
74
-        return array('name','components','template');
74
+        return array('name', 'components', 'template');
75 75
     }
76 76
     
77 77
     /**
@@ -89,7 +89,7 @@  discard block
 block discarded – undo
89 89
      */
90 90
     public function parse_template()
91 91
     {
92
-        return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a){
92
+        return preg_replace_callback('/\{\{([a-zA-Z\d-_]+)\}\}/', function($a) {
93 93
             $component = $this->get_component($a[1]);
94 94
             return $component->render();
95 95
         }, $this->model['template']);
@@ -104,7 +104,7 @@  discard block
 block discarded – undo
104 104
      */
105 105
     public function get_name()
106 106
     {
107
-        if('' !== $this->parent_name)
107
+        if ('' !== $this->parent_name)
108 108
         {
109 109
             return "{$this->parent_name}[{$this->name}]";
110 110
         }
@@ -113,9 +113,9 @@  discard block
 block discarded – undo
113 113
 
114 114
     public function filter($v)
115 115
     {
116
-        foreach($this->components as $component)
116
+        foreach ($this->components as $component)
117 117
         {
118
-            if($component instanceof FilterableComponentInterface &&
118
+            if ($component instanceof FilterableComponentInterface &&
119 119
                \is_callable($component->filter))
120 120
             {
121 121
                 $n = $component->name;
@@ -126,15 +126,15 @@  discard block
 block discarded – undo
126 126
         return $v;
127 127
     }
128 128
 
129
-    public function validation($v,&$e)
129
+    public function validation($v, &$e)
130 130
     {
131
-        foreach($this->components as $component)
131
+        foreach ($this->components as $component)
132 132
         {
133
-            if($component instanceof ValidatableComponentInterface &&
133
+            if ($component instanceof ValidatableComponentInterface &&
134 134
                \is_callable($component->validation))
135 135
             {
136 136
                 $n = $component->name;
137
-                if(!$component->validation($v[$n],$e))
137
+                if (!$component->validation($v[$n], $e))
138 138
                 {
139 139
                     return false;
140 140
                 }
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
      */
149 149
     protected function on_created()
150 150
     {
151
-        foreach( $this->model['components'] as $args )
151
+        foreach ($this->model['components'] as $args)
152 152
         {
153 153
             $this->components[$args['name']] = $this->create_component($args);
154 154
         }
@@ -159,16 +159,16 @@  discard block
 block discarded – undo
159 159
      * @param type $args
160 160
      * @return type
161 161
      */
162
-    private function create_component( $args )
162
+    private function create_component($args)
163 163
     {
164 164
         $type = $args['type'];
165 165
         
166
-        if('composite' === $type)
166
+        if ('composite' === $type)
167 167
         {
168 168
             $args['parent_name'] = $this->get_name();
169 169
         }
170 170
         
171
-        $c = \Amarkal\UI\ComponentFactory::create( $type, $args );
171
+        $c = \Amarkal\UI\ComponentFactory::create($type, $args);
172 172
         
173 173
         // Apply the composite name template
174 174
         $c->name_template = str_replace('{{parent_name}}', $this->get_name(), $c->composite_name_template);
@@ -183,9 +183,9 @@  discard block
 block discarded – undo
183 183
      * @return UI\AbstractComponent
184 184
      * @throws \RuntimeException If there's no child component corresponding to the given name
185 185
      */
186
-    private function get_component( $name )
186
+    private function get_component($name)
187 187
     {
188
-        if(!array_key_exists($name, $this->components))
188
+        if (!array_key_exists($name, $this->components))
189 189
         {
190 190
             throw new \RuntimeException("Composite sub-component not found with name $name");
191 191
         }
Please login to merge, or discard this patch.
components/textarea/controller.php 1 patch
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 class Component_textarea
9 9
 extends AbstractComponent
10 10
 implements ValueComponentInterface, 
11
-           DisableableComponentInterface,
12
-           FilterableComponentInterface,
13
-           ValidatableComponentInterface
11
+            DisableableComponentInterface,
12
+            FilterableComponentInterface,
13
+            ValidatableComponentInterface
14 14
 {
15 15
     public $component_type = 'textarea';
16 16
     
Please login to merge, or discard this patch.
components/number/controller.php 2 patches
Indentation   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -8,9 +8,9 @@
 block discarded – undo
8 8
 class Component_number
9 9
 extends AbstractComponent
10 10
 implements ValueComponentInterface, 
11
-           DisableableComponentInterface,
12
-           FilterableComponentInterface,
13
-           ValidatableComponentInterface
11
+            DisableableComponentInterface,
12
+            FilterableComponentInterface,
13
+            ValidatableComponentInterface
14 14
 {
15 15
     public $component_type = 'number';
16 16
     
Please login to merge, or discard this 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.