Completed
Push — master ( 49228f...024767 )
by Henry Stivens
02:39
created
core/libs/filter/filter.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@  discard block
 block discarded – undo
20 20
 /**
21 21
  * @see FilterInterface
22 22
  * */
23
-require_once __DIR__.'/filter_interface.php';
23
+require_once __DIR__ . '/filter_interface.php';
24 24
 
25 25
 /**
26 26
  * Implementación de Filtros para Kumbia
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
             $options = array();
48 48
             foreach ($filters as $f) {
49
-                $filter_class = Util::camelcase($f).'Filter';
49
+                $filter_class = Util::camelcase($f) . 'Filter';
50 50
                 if (!class_exists($filter_class, false)) {
51 51
                     self::_load_filter($f);
52 52
                 }
@@ -54,7 +54,7 @@  discard block
 block discarded – undo
54 54
                 $s = call_user_func(array($filter_class, 'execute'), $s, $options);
55 55
             }
56 56
         } else {
57
-            $filter_class = Util::camelcase($filter).'Filter';
57
+            $filter_class = Util::camelcase($filter) . 'Filter';
58 58
             if (!class_exists($filter_class, false)) {
59 59
                 self::_load_filter($filter);
60 60
             }
@@ -139,14 +139,14 @@  discard block
 block discarded – undo
139 139
      * especificados en el segundo parametro).
140 140
      */
141 141
     public static function data(array $data, array $fields, $filterAll = '') {
142
-        $filtered = array();//datos filtrados a devolver.
142
+        $filtered = array(); //datos filtrados a devolver.
143 143
         foreach ($fields as $index => $filters) {
144 144
             if (is_numeric($index) && array_key_exists($filters, $data)) {
145 145
                 //si el indice es numerico, no queremos usar filtro para ese campo
146 146
                 $filtered[$filters] = $data[$filters];
147 147
                 continue;
148 148
             } elseif (array_key_exists($index, $data)) {//verificamos de nuevo la existencia del indice en $data
149
-                $filters = explode('|', $filters);//convertimos el filtro en arreglo
149
+                $filters = explode('|', $filters); //convertimos el filtro en arreglo
150 150
                 array_unshift($filters, $data[$index]);
151 151
                 $filtered[$index] = call_user_func_array(array('self', 'get'), $filters);
152 152
                 //$filtered[$index] = self::get($data[$index], $filters); //por ahora sin opciones adicionales.
@@ -186,9 +186,9 @@  discard block
 block discarded – undo
186 186
      * @throw KumbiaException
187 187
      */
188 188
     protected static function _load_filter($filter) {
189
-        $file = APP_PATH."extensions/filters/{$filter}_filter.php";
189
+        $file = APP_PATH . "extensions/filters/{$filter}_filter.php";
190 190
         if (!is_file($file)) {
191
-            $file = __DIR__."/base_filter/{$filter}_filter.php";
191
+            $file = __DIR__ . "/base_filter/{$filter}_filter.php";
192 192
             if (!is_file($file)) {
193 193
                 throw new KumbiaException("Filtro $filter no encontrado");
194 194
             }
Please login to merge, or discard this patch.
core/libs/validate/validations.php 1 patch
Spacing   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -33,7 +33,7 @@  discard block
 block discarded – undo
33 33
     /**
34 34
      * Solo letras
35 35
      */
36
-    const IS_ALPHA    = '/^(?:[^\W\d_]|([ ]))*$/mu';
36
+    const IS_ALPHA = '/^(?:[^\W\d_]|([ ]))*$/mu';
37 37
 
38 38
     /**
39 39
      * Almacena la Expresion Regular
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param  mixed $check Valor a ser chequeado
49 49
      * @return bool
50 50
      */
51
-    public static function numeric($check){
51
+    public static function numeric($check) {
52 52
         return is_numeric($check);
53 53
     }
54 54
 
@@ -74,14 +74,14 @@  discard block
 block discarded – undo
74 74
      */
75 75
     public static function maxlength($value, $param)
76 76
     {
77
-        $max= isset($param['max'])?$param['max']:0;
77
+        $max = isset($param['max']) ? $param['max'] : 0;
78 78
         return !isset($value[$max]);
79 79
     }
80 80
 
81 81
     /**
82 82
      * Valida longitud de la cadena
83 83
      */
84
-    public static function length($value, $param){
84
+    public static function length($value, $param) {
85 85
         $param = array_merge(array(
86 86
             'min' => 0,
87 87
             'max' => 9e100,
@@ -137,7 +137,7 @@  discard block
 block discarded – undo
137 137
      */
138 138
     public static function url($url, $param)
139 139
     {
140
-        $flag = isset($param['flag'])? $param['flag'] : 0;
140
+        $flag = isset($param['flag']) ? $param['flag'] : 0;
141 141
         return filter_var($url, FILTER_VALIDATE_URL, FILTER_FLAG_HOST_REQUIRED | $flag);
142 142
     }
143 143
 
@@ -197,7 +197,7 @@  discard block
 block discarded – undo
197 197
      */
198 198
     public static function date($value, $param)
199 199
     {
200
-        $format = isset($param['format'])? $param['format'] : 'Y-m-d';
200
+        $format = isset($param['format']) ? $param['format'] : 'Y-m-d';
201 201
         $date = DateTime::createFromFormat($format, $value);
202 202
         return $date && $date->format($format) == $value;
203 203
     }
@@ -211,7 +211,7 @@  discard block
 block discarded – undo
211 211
      */
212 212
     public static function pattern($check, $param)
213 213
     {
214
-        $regex = isset($param['regexp'])? $param['regexp'] : '/.*/';
214
+        $regex = isset($param['regexp']) ? $param['regexp'] : '/.*/';
215 215
         return empty($check) || FALSE !== filter_var($check, FILTER_VALIDATE_REGEXP, array('options' => array('regexp' => $regex)));
216 216
     }
217 217
 
@@ -224,7 +224,7 @@  discard block
 block discarded – undo
224 224
      */
225 225
     public static function decimal($value, $param)
226 226
     {
227
-        $decimal = isset($param['decimal'])? $param['decimal'] : ',';
227
+        $decimal = isset($param['decimal']) ? $param['decimal'] : ',';
228 228
         return filter_var($value, FILTER_VALIDATE_FLOAT, array('options' => array('decimal' => $decimal)));
229 229
     }
230 230
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
      */
239 239
     public static function equal($value, $param, $obj)
240 240
     {
241
-        $equal = isset($param['to'])? $param['to'] : '';
241
+        $equal = isset($param['to']) ? $param['to'] : '';
242 242
         return ($obj->$equal == $value);
243 243
     }
244 244
 
@@ -247,8 +247,8 @@  discard block
 block discarded – undo
247 247
      * @param string $key
248 248
      * @return string
249 249
      */
250
-    public static function getMessage($key){
251
-        $arr  = array(
250
+    public static function getMessage($key) {
251
+        $arr = array(
252 252
             'required' => 'Este campo es requerido',
253 253
             'alphanum' => 'Debe ser un valor alfanumérico',
254 254
             'alpha'    => 'Solo caracteres alfabeticos',
Please login to merge, or discard this patch.
core/libs/validate/validate.php 1 patch
Spacing   +26 added lines, -26 removed lines patch added patch discarded remove patch
@@ -19,7 +19,7 @@  discard block
 block discarded – undo
19 19
  * @copyright  Copyright (c) 2005 - 2017 Kumbia Team (http://www.kumbiaphp.com)
20 20
  * @license    http://wiki.kumbiaphp.com/Licencia     New BSD License
21 21
  */
22
-require __DIR__.'/validations.php';
22
+require __DIR__ . '/validations.php';
23 23
 class Validate
24 24
 {
25 25
     /**
@@ -63,9 +63,9 @@  discard block
 block discarded – undo
63 63
      * @param mixed $obj Objecto o Array a validar
64 64
      * @param array $rules Aray de reglas a validar
65 65
      */
66
-    public function __construct($obj, Array $rules){
66
+    public function __construct($obj, Array $rules) {
67 67
         $this->is_obj = is_object($obj);
68
-        $this->obj = (object)$obj;
68
+        $this->obj = (object) $obj;
69 69
         $this->rules = $rules;
70 70
     }
71 71
 
@@ -73,20 +73,20 @@  discard block
 block discarded – undo
73 73
      * Ejecuta las validaciones
74 74
      * @return bool Devuelve true si todo es válido
75 75
      */
76
-    public function exec(){
76
+    public function exec() {
77 77
         /*Recorrido por todos los campos*/
78
-        foreach ($this->rules as $field => $fRule){
78
+        foreach ($this->rules as $field => $fRule) {
79 79
             $value = self::getValue($this->obj, $field);
80 80
             /*Regla individual para cada campo*/
81 81
             foreach ($fRule as $ruleName => $param) {
82 82
                 $ruleName = self::getRuleName($ruleName, $param);
83
-                $param =  self::getParams($param);
83
+                $param = self::getParams($param);
84 84
                 /*Ignore the rule is starts with "#"*/
85
-                if($ruleName[0] == '#') continue;
85
+                if ($ruleName[0] == '#') continue;
86 86
                 /*Es una validación de modelo*/
87
-                if($ruleName[0] == '@'){
87
+                if ($ruleName[0] == '@') {
88 88
                     $this->modelRule($ruleName, $param, $field);
89
-                }elseif(!Validations::$ruleName($value, $param, $this->obj)){
89
+                }elseif (!Validations::$ruleName($value, $param, $this->obj)) {
90 90
                     $this->addError($param, $field, $ruleName);
91 91
                 }
92 92
             }
@@ -102,18 +102,18 @@  discard block
 block discarded – undo
102 102
      * @param string $field Nombre del campo
103 103
      * @return bool
104 104
      */
105
-    protected function modelRule($rule, $param, $field){
106
-        if(!$this->is_obj){
105
+    protected function modelRule($rule, $param, $field) {
106
+        if (!$this->is_obj) {
107 107
             trigger_error('No se puede ejecutar una validacion de modelo en un array', E_USER_WARNING);
108 108
             return false;
109 109
         }
110 110
         $ruleName = ltrim($rule, '@');
111 111
         $obj = $this->obj;
112
-        if(!method_exists($obj, $ruleName)){
112
+        if (!method_exists($obj, $ruleName)) {
113 113
             trigger_error('El metodo para la validacion no existe', E_USER_WARNING);
114 114
             return false;
115 115
         }
116
-        if(!$obj->$ruleName($field, $param)){
116
+        if (!$obj->$ruleName($field, $param)) {
117 117
            $this->addError($param, $field, $ruleName);
118 118
         }
119 119
         return true;
@@ -125,9 +125,9 @@  discard block
 block discarded – undo
125 125
      * @param string $field Nombre del campo
126 126
      * @param string $rule Nombre de la regla
127 127
      */
128
-    protected function addError(Array $param, $field, $rule){
128
+    protected function addError(Array $param, $field, $rule) {
129 129
          $this->messages[$field][] = isset($param['error']) ?
130
-                $param['error']: Validations::getMessage($rule);
130
+                $param['error'] : Validations::getMessage($rule);
131 131
     }
132 132
 
133 133
     /**
@@ -136,9 +136,9 @@  discard block
 block discarded – undo
136 136
      * @param mixed $param
137 137
      * @return string
138 138
      */
139
-    protected static function getRuleName($ruleName, $param){
139
+    protected static function getRuleName($ruleName, $param) {
140 140
          /*Evita tener que colocar un null cuando no se pasan parametros*/
141
-        return is_integer($ruleName) && is_string($param)?$param:$ruleName;
141
+        return is_integer($ruleName) && is_string($param) ? $param : $ruleName;
142 142
     }
143 143
 
144 144
     /**
@@ -146,8 +146,8 @@  discard block
 block discarded – undo
146 146
      * @param mixed $param
147 147
      * @return array
148 148
      */
149
-    protected static function getParams($param){
150
-        return is_array($param)?$param:array();
149
+    protected static function getParams($param) {
150
+        return is_array($param) ? $param : array();
151 151
     }
152 152
 
153 153
     /**
@@ -156,35 +156,35 @@  discard block
 block discarded – undo
156 156
      * @param string $field
157 157
      * @return mixed
158 158
      */
159
-    protected static function getValue($obj, $field){
160
-        return !empty($obj->$field)?$obj->$field:null;//obtengo el valor del campo
159
+    protected static function getValue($obj, $field) {
160
+        return !empty($obj->$field) ? $obj->$field : null; //obtengo el valor del campo
161 161
     }
162 162
 
163 163
     /**
164 164
      * Devuelve los mensajes de error
165 165
      *
166 166
      */
167
-    public function getMessages(){
167
+    public function getMessages() {
168 168
         return $this->messages;
169 169
     }
170 170
 
171 171
     /**
172 172
      * Version de instancias para flush error
173 173
      */
174
-    public function flash(){
174
+    public function flash() {
175 175
         self::errorToFlash($this->getMessages());
176 176
     }
177 177
 
178
-    public static function fail($obj, Array $rules){
178
+    public static function fail($obj, Array $rules) {
179 179
         $val = new self($obj, $rules);
180
-        return $val->exec() ? false:$val->getMessages();
180
+        return $val->exec() ? false : $val->getMessages();
181 181
     }
182 182
 
183 183
     /**
184 184
      * Envia los mensajes de error via flash
185 185
      * @param Array $error
186 186
      */
187
-    public static function errorToFlash(Array $error){
187
+    public static function errorToFlash(Array $error) {
188 188
         foreach ($error as $value)
189 189
             Flash::error($value);
190 190
     }
Please login to merge, or discard this patch.
core/libs/rest/rest.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
      * @param string $accept Cada uno de los tipos separados por coma ','
67 67
      */
68 68
     static public function accept($accept) {
69
-        self::$_outputFormat = is_array($accept)?$accept:explode(',', $accept);
69
+        self::$_outputFormat = is_array($accept) ? $accept : explode(',', $accept);
70 70
     }
71 71
 
72 72
     /**
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
      * @param Controller $controller controlador que se convertira en un servicio REST
76 76
      */
77 77
     static public function init(Controller $controller) {
78
-        $content = isset($_SERVER['CONTENT_TYPE'])?$_SERVER['CONTENT_TYPE']:'text/html';
78
+        $content = isset($_SERVER['CONTENT_TYPE']) ? $_SERVER['CONTENT_TYPE'] : 'text/html';
79 79
         /**
80 80
          * Verifico el formato de entrada
81 81
          */
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
          * Si la acción del controlador es un numero lo pasamos a los parametros
106 106
          */
107 107
         if (is_numeric($controller->action_name)) {
108
-            $controller->parameters = array($controller->action_name)+Rest::param();
108
+            $controller->parameters = array($controller->action_name) + Rest::param();
109 109
         } else {
110 110
             $controller->parameters = Rest::param();
111 111
         }
@@ -115,8 +115,8 @@  discard block
 block discarded – undo
115 115
          * la peticion: get , put, post, delete, etc.
116 116
          */
117 117
         $controller->action_name  = self::$_method;
118
-        $controller->limit_params = FALSE;//no hay verificación en el numero de parametros.
119
-        $controller->data         = array();//variable por defecto para las vistas.
118
+        $controller->limit_params = FALSE; //no hay verificación en el numero de parametros.
119
+        $controller->data         = array(); //variable por defecto para las vistas.
120 120
 
121 121
     }
122 122
 
Please login to merge, or discard this patch.
core/libs/event/event.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -20,7 +20,7 @@
 block discarded – undo
20 20
 /**
21 21
  * @see Hook
22 22
  */
23
-require CORE_PATH.'libs/event/hook.php';
23
+require CORE_PATH . 'libs/event/hook.php';
24 24
 
25 25
 /**
26 26
  * Manejador de eventos
Please login to merge, or discard this patch.
core/libs/input/input.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public static function is($method = '')
31 31
     {
32
-        if($method){
32
+        if ($method) {
33 33
             return $method == $_SERVER['REQUEST_METHOD'];
34 34
         }
35 35
         return $_SERVER['REQUEST_METHOD'];
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
      */
100 100
     public static function hasPost($var)
101 101
     {
102
-        return (bool)self::post($var);
102
+        return (bool) self::post($var);
103 103
     }
104 104
 
105 105
     /**
@@ -110,7 +110,7 @@  discard block
 block discarded – undo
110 110
      */
111 111
     public static function hasGet($var)
112 112
     {
113
-        return (bool)self::get($var);
113
+        return (bool) self::get($var);
114 114
     }
115 115
 
116 116
     /**
@@ -121,7 +121,7 @@  discard block
 block discarded – undo
121 121
      */
122 122
     public static function hasRequest($var)
123 123
     {
124
-        return (bool)self::request($var);
124
+        return (bool) self::request($var);
125 125
     }
126 126
 
127 127
     /**
@@ -132,7 +132,7 @@  discard block
 block discarded – undo
132 132
      */
133 133
     public static function delete($var = '')
134 134
     {
135
-        if($var){
135
+        if ($var) {
136 136
             $_POST[$var] = array();
137 137
         } else {
138 138
             $_POST = array();
@@ -143,7 +143,7 @@  discard block
 block discarded – undo
143 143
     * Permite Obtener el Agente de Usuario (User Agent)
144 144
     * @return String
145 145
     */
146
-    public static function userAgent(){
146
+    public static function userAgent() {
147 147
         return $_SERVER['HTTP_USER_AGENT'];
148 148
     }
149 149
 
@@ -151,12 +151,12 @@  discard block
 block discarded – undo
151 151
     * Permite obtene la IP del cliente, aún cuando usa proxy
152 152
     * @return String
153 153
     */
154
-    public static function ip(){
155
-        if (!empty($_SERVER['HTTP_CLIENT_IP'])){
154
+    public static function ip() {
155
+        if (!empty($_SERVER['HTTP_CLIENT_IP'])) {
156 156
             return $_SERVER['HTTP_CLIENT_IP'];
157
-        }elseif(!empty($_SERVER['HTTP_X_FORWARDED_FOR'])){
157
+        }elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
158 158
             return $_SERVER['HTTP_X_FORWARDED_FOR'];
159
-        }else{
159
+        } else {
160 160
             return $_SERVER['REMOTE_ADDR'];
161 161
         }
162 162
     }
@@ -180,20 +180,20 @@  discard block
 block discarded – undo
180 180
      * @param string $str clave a usar
181 181
      * @return mixed
182 182
      */
183
-    protected static function getFilter(Array $var, $str){
184
-        if(empty($str))
183
+    protected static function getFilter(Array $var, $str) {
184
+        if (empty($str))
185 185
             return filter_var_array($var);
186 186
         $arr = explode('.', $str);
187 187
         $value = $var;
188 188
         foreach ($arr as $key) {
189
-            if(isset($value[$key])){
189
+            if (isset($value[$key])) {
190 190
                 $value = $value[$key];
191
-            } else{
191
+            } else {
192 192
                 $value = NULL;
193 193
                 break;
194 194
             }
195 195
         }
196
-        return is_array($value)?filter_var_array($value): filter_var($value);
196
+        return is_array($value) ? filter_var_array($value) : filter_var($value);
197 197
     }
198 198
 
199 199
 }
Please login to merge, or discard this patch.
core/libs/cache/drivers/sqlite_cache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
      * @param string $group
63 63
      * @return string
64 64
      */
65
-    public function get($id, $group='default')
65
+    public function get($id, $group = 'default')
66 66
     {
67 67
         $this->_id = $id;
68 68
         $this->_group = $group;
@@ -87,7 +87,7 @@  discard block
 block discarded – undo
87 87
      * @param int $lifetime tiempo de vida en forma timestamp de unix
88 88
      * @return boolean
89 89
      */
90
-    public function save($value, $lifetime='', $id='', $group='default')
90
+    public function save($value, $lifetime = '', $id = '', $group = 'default')
91 91
     {
92 92
         if (!$id) {
93 93
             $id = $this->_id;
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
      * @param string $group
123 123
      * @return boolean
124 124
      */
125
-    public function clean($group='')
125
+    public function clean($group = '')
126 126
     {
127 127
         if ($group) {
128 128
             $group = addslashes($group);
@@ -138,7 +138,7 @@  discard block
 block discarded – undo
138 138
      * @param string $group
139 139
      * @return boolean
140 140
      */
141
-    public function remove($id, $group='default')
141
+    public function remove($id, $group = 'default')
142 142
     {
143 143
         $id = addslashes($id);
144 144
         $group = addslashes($group);
Please login to merge, or discard this patch.
core/libs/cache/drivers/file_cache.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -48,7 +48,7 @@  discard block
 block discarded – undo
48 48
      * @param string $group
49 49
      * @return string
50 50
      */
51
-    public function get($id, $group='default')
51
+    public function get($id, $group = 'default')
52 52
     {
53 53
         $this->_id = $id;
54 54
         $this->_group = $group;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param int $lifetime tiempo de vida en forma timestamp de unix
79 79
      * @return bool
80 80
      */
81
-    public function save($value, $lifetime='', $id='', $group='default')
81
+    public function save($value, $lifetime = '', $id = '', $group = 'default')
82 82
     {
83 83
         if (!$id) {
84 84
             $id = $this->_id;
@@ -100,7 +100,7 @@  discard block
 block discarded – undo
100 100
      * @param string $group
101 101
      * @return boolean
102 102
      */
103
-    public function clean($group='')
103
+    public function clean($group = '')
104 104
     {
105 105
         $pattern = $group ? APP_PATH . 'temp/cache/' . '*.' . md5($group) : APP_PATH . 'temp/cache/*';
106 106
         foreach (glob($pattern) as $filename) {
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
      * @param string $group
119 119
      * @return bool
120 120
      */
121
-    public function remove($id, $group='default')
121
+    public function remove($id, $group = 'default')
122 122
     {
123 123
         return unlink(APP_PATH . 'temp/cache/' . $this->_getFilename($id, $group));
124 124
     }
Please login to merge, or discard this patch.
core/libs/cache/drivers/APC_cache.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      * @param string $group
37 37
      * @return string
38 38
      */
39
-    public function get($id, $group='default')
39
+    public function get($id, $group = 'default')
40 40
     {
41 41
         $this->_id = $id;
42 42
         $this->_group = $group;
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
      * @param string $group No se usa con APC
79 79
      * @return boolean
80 80
      */
81
-    public function clean($group=false)
81
+    public function clean($group = false)
82 82
     {
83 83
         return apc_clear_cache('user');
84 84
     }
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      * @param string $group
91 91
      * @return boolean
92 92
      */
93
-    public function remove($id, $group='default')
93
+    public function remove($id, $group = 'default')
94 94
     {
95 95
         return apc_delete("$id.$group");
96 96
     }
Please login to merge, or discard this patch.