Passed
Branch master (49f250)
by Brayan
01:58
created
Ocrend/Kernel/Helpers/Emails.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
      */
47 47
     public static function loadTemplate(array $content, int $template) : string {
48 48
         # Verificar que existe la plantilla
49
-        if(!array_key_exists($template,self::TEMPLATES)) {
49
+        if (!array_key_exists($template, self::TEMPLATES)) {
50 50
             throw new \RuntimeException('La plantilla seleccionada no se encuentra.');
51 51
         }
52 52
 
@@ -54,8 +54,8 @@  discard block
 block discarded – undo
54 54
         $tpl = Files::read_file(self::TEMPLATES_ROUTE . self::TEMPLATES[$template]);
55 55
 
56 56
         # Reempalzar contenido
57
-        foreach($content as $index => $html) {
58
-            $tpl = str_replace($index,$html,$tpl);
57
+        foreach ($content as $index => $html) {
58
+            $tpl = str_replace($index, $html, $tpl);
59 59
         }
60 60
 
61 61
         return $tpl;
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
         $https['ssl']['verify_peer_name'] = false;
91 91
 
92 92
         # Verificar si están llenos los campos
93
-        if(!$config['build']['production'] && Functions::emp($config['mailer']['host'])) {
93
+        if (!$config['build']['production'] && Functions::emp($config['mailer']['host'])) {
94 94
             throw new \RuntimeException('Los datos de mailer, en Ocrend.ini.yml están vacíos.');
95 95
         }
96 96
 
@@ -105,9 +105,9 @@  discard block
 block discarded – undo
105 105
 
106 106
         # El mensaje
107 107
         $message = new \Swift_Message();
108
-        $message->setSubject(array_key_exists('{{title}}',$content) ? $content['{{title}}'] : $config['build']['name']);
109
-        $message->setBody(self::loadTemplate($content,$template), 'text/html');
110
-        $message->setFrom([ $config['mailer']['user'] => $config['build']['name']]);
108
+        $message->setSubject(array_key_exists('{{title}}', $content) ? $content['{{title}}'] : $config['build']['name']);
109
+        $message->setBody(self::loadTemplate($content, $template), 'text/html');
110
+        $message->setFrom([$config['mailer']['user'] => $config['build']['name']]);
111 111
         $message->setTo($dest);
112 112
 
113 113
         # Adjuntos
Please login to merge, or discard this patch.
Ocrend/Kernel/Helpers/Files.php 2 patches
Indentation   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
    * @param string $file_name: Nombre del archivo, da igual si es solo el nombre o la ruta con el nombre
86 86
    *
87 87
    * @return mixed string con la extensión, devuelve un string '' si no existe información alguna acerca de la extensión
88
-  */
88
+   */
89 89
   public static function get_file_ext(string $file_name) {
90 90
     return pathinfo($file_name, PATHINFO_EXTENSION);
91 91
   }
@@ -96,7 +96,7 @@  discard block
 block discarded – undo
96 96
    * @param string $file_name: Nombre del archivo, da igual si es solo el nombre o la ruta con el nombre
97 97
    *
98 98
    * @return bool true si es una imagen, false si no lo es
99
-  */
99
+   */
100 100
   public static function is_image(string $file_name) : bool {
101 101
     return (bool) in_array(self::get_file_ext($file_name), ['jpg', 'png', 'jpeg', 'gif', 'JPG', 'PNG', 'JPEG', 'GIF']);
102 102
   }
@@ -109,7 +109,7 @@  discard block
 block discarded – undo
109 109
    * @return int con el tamaño del fichero
110 110
    */
111 111
   public static function file_size(string $file) : int {
112
-  	return (int) round(filesize($file)*0.0009765625, 1);
112
+    return (int) round(filesize($file)*0.0009765625, 1);
113 113
   }
114 114
 
115 115
   /**
@@ -118,9 +118,9 @@  discard block
 block discarded – undo
118 118
    * @param string $file: path del fichero
119 119
    *
120 120
    * @return string con la fecha del fichero en el formato d-m-y h:i:s
121
-  */
121
+   */
122 122
   public static function date_file(string $file) : string {
123
-  	return date('d-m-Y h:i:s', filemtime($file));
123
+    return date('d-m-Y h:i:s', filemtime($file));
124 124
   }
125 125
 
126 126
   /**
@@ -130,7 +130,7 @@  discard block
 block discarded – undo
130 130
    * @param string $types: tipos de archivos a buscar, por defecto '' significa todos, se puede pasar por ejemplo 'jpg'
131 131
    *
132 132
    * @return array con las rutas de todos los ficheros encontrados, un array vacío si no encontró ficheros
133
-  */
133
+   */
134 134
   public static function get_files_in_dir(string $dir, string $types = '') : array {
135 135
     $array = array();
136 136
     if (is_dir($dir)) {
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
    * @param int $permisos: Permisos del directorio a crear, por defecto es 0655
149 149
    *
150 150
    * @return bool con true si fue creado con éxito, false si el directorio ya existía o hubo algún error
151
-  */
151
+   */
152 152
   public static function create_dir(string $dir, int $permisos = 0655) : bool {
153 153
     if(is_dir($dir)) {
154 154
       return false;
@@ -245,10 +245,10 @@  discard block
 block discarded – undo
245 245
   }
246 246
 
247 247
   /**
248
-    * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig
249
-    *
250
-    * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig
251
-  */
248
+   * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig
249
+   *
250
+   * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig
251
+   */
252 252
   public function getFunctions() : array {
253 253
     return array(
254 254
       new \Twig_Function('images_in_dir', array($this, 'images_in_dir')),
@@ -261,10 +261,10 @@  discard block
 block discarded – undo
261 261
   }
262 262
 
263 263
   /**
264
-    * Identificador único para la extensión de twig
265
-    *
266
-    * @return string con el nombre de la extensión
267
-  */
264
+   * Identificador único para la extensión de twig
265
+   *
266
+   * @return string con el nombre de la extensión
267
+   */
268 268
   public function getName() : string {
269 269
     return 'ocrend_framework_helper_files';
270 270
   }
Please login to merge, or discard this patch.
Spacing   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@  discard block
 block discarded – undo
45 45
    * @return int catidad de bytes escritos en el archivo
46 46
    */
47 47
   public static function write_file(string $dir, string $content) : int {
48
-    $f = new \SplFileObject($dir,'w');
48
+    $f = new \SplFileObject($dir, 'w');
49 49
     return (int) $f->fwrite($content);
50 50
   }
51 51
 
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
    * @return int : catidad de bytes escritos en el archivo
59 59
    */
60 60
   public static function write_in_file(string $dir, string $content) : int {
61
-    $f = new \SplFileObject($dir,'a+');
61
+    $f = new \SplFileObject($dir, 'a+');
62 62
     return (int) $f->fwrite("\n\r" . $content);
63 63
   }
64 64
 
@@ -150,11 +150,11 @@  discard block
 block discarded – undo
150 150
    * @return bool con true si fue creado con éxito, false si el directorio ya existía o hubo algún error
151 151
   */
152 152
   public static function create_dir(string $dir, int $permisos = 0655) : bool {
153
-    if(is_dir($dir)) {
153
+    if (is_dir($dir)) {
154 154
       return false;
155 155
     }
156 156
     
157
-    return (bool) mkdir($dir,$permisos,true);
157
+    return (bool) mkdir($dir, $permisos, true);
158 158
   }
159 159
 
160 160
 
@@ -226,19 +226,19 @@  discard block
 block discarded – undo
226 226
    *
227 227
    * @return void
228 228
    */
229
-  public static function move_from_dir(string $old_dir, string $new_dir, bool $only_images = false, bool $delete_old = false)  {
229
+  public static function move_from_dir(string $old_dir, string $new_dir, bool $only_images = false, bool $delete_old = false) {
230 230
     self::create_dir($new_dir);
231 231
 
232
-    foreach(glob($old_dir . ($only_images ? '{*.jpg,*.gif,*.png,*.gif,*.jpeg,*.JPG,*.GIF,*.PNG,*.JPEG}' : '*'),GLOB_BRACE) as $file) {
233
-      if(file_exists($file)) {
232
+    foreach (glob($old_dir . ($only_images ? '{*.jpg,*.gif,*.png,*.gif,*.jpeg,*.JPG,*.GIF,*.PNG,*.JPEG}' : '*'), GLOB_BRACE) as $file) {
233
+      if (file_exists($file)) {
234 234
           unlink($file);
235 235
       }
236 236
       
237
-      $name = explode('/',$file);
237
+      $name = explode('/', $file);
238 238
       $name = end($name);
239
-      copy($file,$new_dir . $name);
239
+      copy($file, $new_dir . $name);
240 240
 
241
-      if($delete_old) {
241
+      if ($delete_old) {
242 242
         unlink($file);
243 243
       }
244 244
     }
Please login to merge, or discard this patch.
Ocrend/Kernel/Helpers/Arrays.php 1 patch
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -94,12 +94,12 @@  discard block
 block discarded – undo
94 94
   }
95 95
 
96 96
   /**
97
-    * Evalúa si un arreglo es de tipo asociativo o no
98
-    *
99
-    * @param array $a: Arreglo a evaluar
100
-    *
101
-    * @return bool false si no lo es, true si lo es
102
-  */
97
+   * Evalúa si un arreglo es de tipo asociativo o no
98
+   *
99
+   * @param array $a: Arreglo a evaluar
100
+   *
101
+   * @return bool false si no lo es, true si lo es
102
+   */
103 103
   public static function is_assoc(array $a) : bool {
104 104
     if (sizeof($a) == 0) {
105 105
       return false;
@@ -109,36 +109,36 @@  discard block
 block discarded – undo
109 109
   }
110 110
 
111 111
   /**
112
-    * Evalúa si un arreglo es secuencial (de índices numéricos)
113
-    *
114
-    * @param array $a: Arreglo a evaluar
115
-    *
116
-    * @return bool false si no lo es, true si lo es
117
-  */
112
+   * Evalúa si un arreglo es secuencial (de índices numéricos)
113
+   *
114
+   * @param array $a: Arreglo a evaluar
115
+   *
116
+   * @return bool false si no lo es, true si lo es
117
+   */
118 118
   public static function is_numeric_array(array $a) : bool {
119 119
     return !self::is_assoc($a);
120 120
   }
121 121
 
122 122
   /**
123
-    * Obtiene de forma random un elemento de un arreglo
124
-    *
125
-    * @param array $a: Arreglo a evaluar
126
-    *
127
-    * @return mixed elemento random dentro del arreglo
128
-  */
123
+   * Obtiene de forma random un elemento de un arreglo
124
+   *
125
+   * @param array $a: Arreglo a evaluar
126
+   *
127
+   * @return mixed elemento random dentro del arreglo
128
+   */
129 129
   public static function array_random_element(array $a) {
130 130
     return $a[array_rand($a)];
131 131
   }
132 132
 
133 133
   /**
134
-    * Ordena una matriz de mayor a menor, o menor a mayor por el valor de un campo específico
135
-    *
136
-    * @param array $toOrderArray : Arreglo a evaluar
137
-    * @param string $field: Campo por el que se va a ordenar
138
-    * @param bool $inverse: Por defecto falso, cambia el orden
139
-    *
140
-    * @return mixed elemento random dentro del arreglo
141
-  */
134
+   * Ordena una matriz de mayor a menor, o menor a mayor por el valor de un campo específico
135
+   *
136
+   * @param array $toOrderArray : Arreglo a evaluar
137
+   * @param string $field: Campo por el que se va a ordenar
138
+   * @param bool $inverse: Por defecto falso, cambia el orden
139
+   *
140
+   * @return mixed elemento random dentro del arreglo
141
+   */
142 142
   public static function order_multi_dimensional(array $toOrderArray, string $field, bool $inverse = false) : array {
143 143
     $position = array();
144 144
     $newRow = array();
@@ -157,10 +157,10 @@  discard block
 block discarded – undo
157 157
   }
158 158
 
159 159
   /**
160
-    * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig
161
-    *
162
-    * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig
163
-  */
160
+   * Se obtiene de Twig_Extension y sirve para que cada función esté disponible como etiqueta en twig
161
+   *
162
+   * @return array con todas las funciones con sus respectivos nombres de acceso en plantillas twig
163
+   */
164 164
   public function getFunctions() : array {
165 165
     return array(
166 166
       new \Twig_Function('get_key_by_index', array($this, 'get_key_by_index')),
@@ -173,10 +173,10 @@  discard block
 block discarded – undo
173 173
   }
174 174
 
175 175
   /**
176
-    * Identificador único para la extensión de twig
177
-    *
178
-    * @return string con el nombre de la extensión
179
-  */
176
+   * Identificador único para la extensión de twig
177
+   *
178
+   * @return string con el nombre de la extensión
179
+   */
180 180
   public function getName() : string {
181 181
     return 'ocrend_framework_helper_arrays';
182 182
   }
Please login to merge, or discard this patch.
Ocrend/Kernel/Helpers/Functions.php 2 patches
Indentation   +83 added lines, -83 removed lines patch added patch discarded remove patch
@@ -27,7 +27,7 @@  discard block
 block discarded – undo
27 27
    * @param int $max: Valor a comparar
28 28
    *
29 29
    * @return bool con el resultado de la comparación
30
-  */
30
+   */
31 31
   private static function check_str_to_time(int $index, array $detail, int $max) : bool {
32 32
     return !array_key_exists($index,$detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max;
33 33
   }
@@ -38,19 +38,19 @@  discard block
 block discarded – undo
38 38
    * @param array $detail: Arreglo
39 39
    * 
40 40
    * @return bool
41
-  */
41
+   */
42 42
   private static function check_time(array $detail) : bool {
43 43
     return self::check_str_to_time(0,$detail,1) || self::check_str_to_time(1,$detail,1) || intval($detail[1]) > 12 || self::check_str_to_time(2,$detail,1970);
44 44
   }
45 45
 
46 46
   /**
47
-  * Redirecciona a una URL
48
-  *
49
-  * @param string $url: Sitio a donde redireccionará, si no se pasa, por defecto
50
-  * se redirecciona a la URL principal del sitio
51
-  *
52
-  * @return void
53
-  */
47
+   * Redirecciona a una URL
48
+   *
49
+   * @param string $url: Sitio a donde redireccionará, si no se pasa, por defecto
50
+   * se redirecciona a la URL principal del sitio
51
+   *
52
+   * @return void
53
+   */
54 54
   public static function redir($url = null)  {
55 55
     global $config;
56 56
     
@@ -91,7 +91,7 @@  discard block
 block discarded – undo
91 91
    * @param string  $email: El email del usuario a extraer el gravatar
92 92
    * @param int $size: El tamaño del gravatar
93 93
    * @return string con la URl
94
-  */
94
+   */
95 95
   public static function get_gravatar(string $email, int $size = 35) : string  {
96 96
     return 'http://www.gravatar.com/avatar/' . md5($email) . '?s=' . (int) abs($size) . '?d=robohash';
97 97
   }
@@ -108,30 +108,30 @@  discard block
 block discarded – undo
108 108
     return (null === $var || empty(trim(str_replace(' ','',$var))));
109 109
   }
110 110
 
111
-   //------------------------------------------------
111
+    //------------------------------------------------
112 112
 
113
-   /**
113
+    /**
114 114
      * Aanaliza que TODOS los elementos de un arreglo estén llenos, útil para analizar por ejemplo que todos los elementos de un formulario esté llenos
115 115
      * pasando como parámetro $_POST
116 116
      *
117 117
      * @param array $array, arreglo a analizar
118 118
      *
119 119
      * @return bool con true si están todos llenos, false si al menos uno está vacío
120
-   */
121
-   public static function all_full(array $array) : bool {
122
-     foreach($array as $e) {
123
-       if(self::emp($e) and $e != '0') {
124
-         return false;
125
-       }
126
-     }
127
-     return true;
128
-   }
120
+     */
121
+    public static function all_full(array $array) : bool {
122
+      foreach($array as $e) {
123
+        if(self::emp($e) and $e != '0') {
124
+          return false;
125
+        }
126
+      }
127
+      return true;
128
+    }
129 129
 
130 130
   /**
131 131
    * Alias de Empty() pero soporta más de un parámetro (infinitos)
132 132
    *
133 133
    * @return bool con true si al menos uno está vacío, false si todos están llenos
134
-  */
134
+   */
135 135
   public static function e() : bool  {
136 136
     for ($i = 0, $nargs = func_num_args(); $i < $nargs; $i++) {
137 137
       if(self::emp(func_get_arg($i)) && func_get_arg($i) != '0') {
@@ -150,40 +150,40 @@  discard block
 block discarded – undo
150 150
    * @param int $time: Tiempo, por defecto es time() (igual que en date())
151 151
    *
152 152
    * @return string con la fecha en formato humano (y en español)
153
-  */
153
+   */
154 154
   public static function fecha(string $format, int $time = 0) : string  {
155 155
     $date = date($format,$time == 0 ? time() : $time);
156 156
     $cambios = array(
157
-         'Monday'=> 'Lunes',
158
-         'Tuesday'=> 'Martes',
159
-         'Wednesday'=> 'Miércoles',
160
-         'Thursday'=> 'Jueves',
161
-         'Friday'=> 'Viernes',
162
-         'Saturday'=> 'Sábado',
163
-         'Sunday'=> 'Domingo',
164
-         'January'=> 'Enero',
165
-         'February'=> 'Febrero',
166
-         'March'=> 'Marzo',
167
-         'April'=> 'Abril',
168
-         'May'=> 'Mayo',
169
-         'June'=> 'Junio',
170
-         'July'=> 'Julio',
171
-         'August'=> 'Agosto',
172
-         'September'=> 'Septiembre',
173
-         'October'=> 'Octubre',
174
-         'November'=> 'Noviembre',
175
-         'December'=> 'Diciembre',
176
-         'Mon'=> 'Lun',
177
-         'Tue'=> 'Mar',
178
-         'Wed'=> 'Mie',
179
-         'Thu'=> 'Jue',
180
-         'Fri'=> 'Vie',
181
-         'Sat'=> 'Sab',
182
-         'Sun'=> 'Dom',
183
-         'Jan'=> 'Ene',
184
-         'Aug'=> 'Ago',
185
-         'Apr'=> 'Abr',
186
-         'Dec'=> 'Dic'
157
+          'Monday'=> 'Lunes',
158
+          'Tuesday'=> 'Martes',
159
+          'Wednesday'=> 'Miércoles',
160
+          'Thursday'=> 'Jueves',
161
+          'Friday'=> 'Viernes',
162
+          'Saturday'=> 'Sábado',
163
+          'Sunday'=> 'Domingo',
164
+          'January'=> 'Enero',
165
+          'February'=> 'Febrero',
166
+          'March'=> 'Marzo',
167
+          'April'=> 'Abril',
168
+          'May'=> 'Mayo',
169
+          'June'=> 'Junio',
170
+          'July'=> 'Julio',
171
+          'August'=> 'Agosto',
172
+          'September'=> 'Septiembre',
173
+          'October'=> 'Octubre',
174
+          'November'=> 'Noviembre',
175
+          'December'=> 'Diciembre',
176
+          'Mon'=> 'Lun',
177
+          'Tue'=> 'Mar',
178
+          'Wed'=> 'Mie',
179
+          'Thu'=> 'Jue',
180
+          'Fri'=> 'Vie',
181
+          'Sat'=> 'Sab',
182
+          'Sun'=> 'Dom',
183
+          'Jan'=> 'Ene',
184
+          'Aug'=> 'Ago',
185
+          'Apr'=> 'Abr',
186
+          'Dec'=> 'Dic'
187 187
     );
188 188
     return str_replace(array_keys($cambios), array_values($cambios), $date);
189 189
   }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
    *  Se adapta a la configuración del dominio en general.
194 194
    *
195 195
    * @return string <base href="ruta" />
196
-  */
196
+   */
197 197
   public static function base_assets() : string {
198 198
     global $config, $http;
199 199
 
@@ -231,7 +231,7 @@  discard block
 block discarded – undo
231 231
    * @param int $anio: Año (1975 a 2xxx)
232 232
    *
233 233
    * @return string con el número del día
234
-  */
234
+   */
235 235
   public static function last_day_month(int $mes, int $anio) : string {
236 236
     return date('d', (mktime(0,0,0,$mes + 1, 1, $anio) - 1));
237 237
   }
@@ -290,19 +290,19 @@  discard block
 block discarded – undo
290 290
 
291 291
     # Arreglo de condiciones y subcondiciones
292 292
     $fecha = array(
293
-       1 => date('d/m/Y', time()),
294
-       2 => date('d/m/Y', time() - (60*60*24)),
295
-       3 => array(
296
-         'Mon' => $hoy[0],
297
-         'Tue' => intval($hoy[0]) - 1,
298
-         'Wed' => intval($hoy[0]) - 2,
299
-         'Thu' => intval($hoy[0]) - 3,
300
-         'Fri' => intval($hoy[0]) - 4,
301
-         'Sat' => intval($hoy[0]) - 5,
302
-         'Sun' => intval($hoy[0]) - 6
303
-       ),
304
-       4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2],
305
-       5 => '01/01/' . $hoy[2]
293
+        1 => date('d/m/Y', time()),
294
+        2 => date('d/m/Y', time() - (60*60*24)),
295
+        3 => array(
296
+          'Mon' => $hoy[0],
297
+          'Tue' => intval($hoy[0]) - 1,
298
+          'Wed' => intval($hoy[0]) - 2,
299
+          'Thu' => intval($hoy[0]) - 3,
300
+          'Fri' => intval($hoy[0]) - 4,
301
+          'Sat' => intval($hoy[0]) - 5,
302
+          'Sun' => intval($hoy[0]) - 6
303
+        ),
304
+        4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2],
305
+        5 => '01/01/' . $hoy[2]
306 306
     );
307 307
 
308 308
     if($desde == 3) {
@@ -347,22 +347,22 @@  discard block
 block discarded – undo
347 347
    */
348 348
   public function getFunctions() : array {
349 349
     return array(
350
-       new \Twig_Function('percent', array($this, 'percent')),
351
-       new \Twig_Function('convert', array($this, 'convert')),
352
-       new \Twig_Function('get_gravatar', array($this, 'get_gravatar')),
353
-       new \Twig_Function('emp', array($this, 'emp')),
354
-       new \Twig_Function('e_dynamic', array($this, 'e')),
355
-       new \Twig_Function('all_full', array($this, 'all_full')),
356
-       new \Twig_Function('fecha', array($this, 'fecha')),
357
-       new \Twig_Function('base_assets', array($this, 'base_assets')),
358
-       new \Twig_Function('timestamp', array($this, 'timestamp')),
359
-       new \Twig_Function('desde_date', array($this, 'desde_date')),
360
-       new \Twig_Function('cero_izq', array($this, 'cero_izq')),
361
-       new \Twig_Function('last_day_month', array($this, 'last_day_month')),
362
-       new \Twig_Function('str_to_time', array($this, 'str_to_time')),
363
-       new \Twig_Function('desde_date', array($this, 'desde_date'))
350
+        new \Twig_Function('percent', array($this, 'percent')),
351
+        new \Twig_Function('convert', array($this, 'convert')),
352
+        new \Twig_Function('get_gravatar', array($this, 'get_gravatar')),
353
+        new \Twig_Function('emp', array($this, 'emp')),
354
+        new \Twig_Function('e_dynamic', array($this, 'e')),
355
+        new \Twig_Function('all_full', array($this, 'all_full')),
356
+        new \Twig_Function('fecha', array($this, 'fecha')),
357
+        new \Twig_Function('base_assets', array($this, 'base_assets')),
358
+        new \Twig_Function('timestamp', array($this, 'timestamp')),
359
+        new \Twig_Function('desde_date', array($this, 'desde_date')),
360
+        new \Twig_Function('cero_izq', array($this, 'cero_izq')),
361
+        new \Twig_Function('last_day_month', array($this, 'last_day_month')),
362
+        new \Twig_Function('str_to_time', array($this, 'str_to_time')),
363
+        new \Twig_Function('desde_date', array($this, 'desde_date'))
364 364
     );
365
-   }
365
+    }
366 366
 
367 367
   /**
368 368
    * Identificador único para la extensión de twig
Please login to merge, or discard this patch.
Spacing   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -29,7 +29,7 @@  discard block
 block discarded – undo
29 29
    * @return bool con el resultado de la comparación
30 30
   */
31 31
   private static function check_str_to_time(int $index, array $detail, int $max) : bool {
32
-    return !array_key_exists($index,$detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max;
32
+    return !array_key_exists($index, $detail) || !is_numeric($detail[$index]) || intval($detail[$index]) < $max;
33 33
   }
34 34
 
35 35
   /**
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
    * @return bool
41 41
   */
42 42
   private static function check_time(array $detail) : bool {
43
-    return self::check_str_to_time(0,$detail,1) || self::check_str_to_time(1,$detail,1) || intval($detail[1]) > 12 || self::check_str_to_time(2,$detail,1970);
43
+    return self::check_str_to_time(0, $detail, 1) || self::check_str_to_time(1, $detail, 1) || intval($detail[1]) > 12 || self::check_str_to_time(2, $detail, 1970);
44 44
   }
45 45
 
46 46
   /**
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
51 51
   *
52 52
   * @return void
53 53
   */
54
-  public static function redir($url = null)  {
54
+  public static function redir($url = null) {
55 55
     global $config;
56 56
     
57 57
     if (null == $url) {
@@ -105,7 +105,7 @@  discard block
 block discarded – undo
105 105
    * @return bool con true si está vacío, false si no, un espacio en blanco cuenta como vacío
106 106
    */
107 107
   public static function emp($var) : bool {
108
-    return (null === $var || empty(trim(str_replace(' ','',$var))));
108
+    return (null === $var || empty(trim(str_replace(' ', '', $var))));
109 109
   }
110 110
 
111 111
    //------------------------------------------------
@@ -119,8 +119,8 @@  discard block
 block discarded – undo
119 119
      * @return bool con true si están todos llenos, false si al menos uno está vacío
120 120
    */
121 121
    public static function all_full(array $array) : bool {
122
-     foreach($array as $e) {
123
-       if(self::emp($e) and $e != '0') {
122
+     foreach ($array as $e) {
123
+       if (self::emp($e) and $e != '0') {
124 124
          return false;
125 125
        }
126 126
      }
@@ -134,7 +134,7 @@  discard block
 block discarded – undo
134 134
   */
135 135
   public static function e() : bool  {
136 136
     for ($i = 0, $nargs = func_num_args(); $i < $nargs; $i++) {
137
-      if(self::emp(func_get_arg($i)) && func_get_arg($i) != '0') {
137
+      if (self::emp(func_get_arg($i)) && func_get_arg($i) != '0') {
138 138
         return true;
139 139
       }
140 140
     }
@@ -152,7 +152,7 @@  discard block
 block discarded – undo
152 152
    * @return string con la fecha en formato humano (y en español)
153 153
   */
154 154
   public static function fecha(string $format, int $time = 0) : string  {
155
-    $date = date($format,$time == 0 ? time() : $time);
155
+    $date = date($format, $time == 0 ? time() : $time);
156 156
     $cambios = array(
157 157
          'Monday'=> 'Lunes',
158 158
          'Tuesday'=> 'Martes',
@@ -199,9 +199,9 @@  discard block
 block discarded – undo
199 199
 
200 200
     # Revisar protocolo
201 201
     $https = 'http://';
202
-    if($config['router']['ssl']) {
202
+    if ($config['router']['ssl']) {
203 203
       # Revisar el protocolo
204
-      if(true == $http->server->get('HTTPS')
204
+      if (true == $http->server->get('HTTPS')
205 205
         || $http->server->get('HTTPS') == 'on' 
206 206
         || $http->server->get('HTTPS') == 1) {
207 207
         $https = 'https://';
@@ -210,7 +210,7 @@  discard block
 block discarded – undo
210 210
 
211 211
     # Revisar el path
212 212
     $path = $config['router']['path'];
213
-    if('/' != substr($path, -1)) {
213
+    if ('/' != substr($path, -1)) {
214 214
       $path .= '/';
215 215
     }
216 216
 
@@ -233,7 +233,7 @@  discard block
 block discarded – undo
233 233
    * @return string con el número del día
234 234
   */
235 235
   public static function last_day_month(int $mes, int $anio) : string {
236
-    return date('d', (mktime(0,0,0,$mes + 1, 1, $anio) - 1));
236
+    return date('d', (mktime(0, 0, 0, $mes + 1, 1, $anio) - 1));
237 237
   }
238 238
   
239 239
   /**
@@ -256,10 +256,10 @@  discard block
 block discarded – undo
256 256
    * @return int|null con el timestamp
257 257
    */
258 258
   public static function str_to_time($fecha, string $hora = '00:00:00') {
259
-    $detail = explode('/',$fecha ?? '');
259
+    $detail = explode('/', $fecha ?? '');
260 260
 
261 261
     // Formato de día incorrecto, mes y año incorrectos
262
-    if(self::check_time($detail)) {
262
+    if (self::check_time($detail)) {
263 263
       return null;
264 264
     }
265 265
 
@@ -285,8 +285,8 @@  discard block
 block discarded – undo
285 285
    */
286 286
   public static function desde_date(int $desde) {
287 287
     # Obtener esta fecha
288
-    $hoy = date('d/m/Y/D',time());
289
-    $hoy = explode('/',$hoy);
288
+    $hoy = date('d/m/Y/D', time());
289
+    $hoy = explode('/', $hoy);
290 290
 
291 291
     # Arreglo de condiciones y subcondiciones
292 292
     $fecha = array(
@@ -301,21 +301,21 @@  discard block
 block discarded – undo
301 301
          'Sat' => intval($hoy[0]) - 5,
302 302
          'Sun' => intval($hoy[0]) - 6
303 303
        ),
304
-       4 => '01/'. self::cero_izq($hoy[1]) .'/' . $hoy[2],
304
+       4 => '01/' . self::cero_izq($hoy[1]) . '/' . $hoy[2],
305 305
        5 => '01/01/' . $hoy[2]
306 306
     );
307 307
 
308
-    if($desde == 3) {
308
+    if ($desde == 3) {
309 309
       # Dia actual
310 310
       $dia = $fecha[3][$hoy[3]];
311 311
 
312 312
       # Mes anterior y posiblemente, año también.
313
-      if($dia == 0) {
313
+      if ($dia == 0) {
314 314
         # Restante de la fecha
315
-        $real_fecha = self::last_day_month($hoy[1],$hoy[2]) .'/'. self::cero_izq($hoy[1] - 1) .'/';
315
+        $real_fecha = self::last_day_month($hoy[1], $hoy[2]) . '/' . self::cero_izq($hoy[1] - 1) . '/';
316 316
 
317 317
         # Verificamos si estamos en enero
318
-        if($hoy[1] == 1) {
318
+        if ($hoy[1] == 1) {
319 319
           return  $real_fecha . ($hoy[2] - 1);
320 320
         }
321 321
         
@@ -323,8 +323,8 @@  discard block
 block discarded – undo
323 323
         return $real_fecha . $hoy[2];
324 324
       }
325 325
       
326
-      return self::cero_izq($dia) .'/'. self::cero_izq($hoy[1]) .'/' . $hoy[2];
327
-    } else if(array_key_exists($desde,$fecha)) {
326
+      return self::cero_izq($dia) . '/' . self::cero_izq($hoy[1]) . '/' . $hoy[2];
327
+    } else if (array_key_exists($desde, $fecha)) {
328 328
       return $fecha[$desde];
329 329
     }
330 330
 
Please login to merge, or discard this patch.
Ocrend/Kernel/Helpers/Strings.php 2 patches
Indentation   +12 added lines, -12 removed lines patch added patch discarded remove patch
@@ -26,7 +26,7 @@  discard block
 block discarded – undo
26 26
    * @param int|null $to: Tiempo en segundo hasta donde se desea contar, si no se pasa por defecto es el tiempo actual
27 27
    *
28 28
    * @return string con la forma: hace 20 segundos, hace 1 minuto, hace 2 horas, hace 4 días, hace 1 semana, hace 3 meses, hace 1 año ...
29
-  */
29
+   */
30 30
   public static function amigable_time(int $from, $to = null) : string {   
31 31
     $intervalos = ['segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año'];
32 32
     $duraciones = ['60','60','24','7','4.35','12'];
@@ -62,7 +62,7 @@  discard block
 block discarded – undo
62 62
    * @example Strings::chash('$2a$10$87b2b603324793cc37f8dOPFTnHRY0lviq5filK5cN4aMCQDJcC9G','123456'); //return true
63 63
    *
64 64
    * @return bool true si $s2 contiene la misma llave que $hash, por tanto el contenido de $hash es $s2, de lo contrario false
65
-  */
65
+   */
66 66
   public static function chash(string $hash, string $s2) : bool  {
67 67
     return $hash == crypt($s2, substr($hash, 0, 29));
68 68
   }
@@ -177,12 +177,12 @@  discard block
 block discarded – undo
177 177
   }
178 178
 
179 179
   /**
180
-    * Remueve todos los espacios en blanco de un string
181
-    *
182
-    * @param string $s: Cadena de texto a convertir
183
-    *
184
-    * @return string del texto sin espacios
185
-  */
180
+   * Remueve todos los espacios en blanco de un string
181
+   *
182
+   * @param string $s: Cadena de texto a convertir
183
+   *
184
+   * @return string del texto sin espacios
185
+   */
186 186
   public static function remove_spaces(string $s) : string {
187 187
     return trim(str_replace(' ', '', $s));
188 188
   }
@@ -193,7 +193,7 @@  discard block
 block discarded – undo
193 193
    * @param string $s: Cadena de texto a verificar
194 194
    *
195 195
    * @return bool, verdadero si es alfanumerica, falso si no
196
-  */
196
+   */
197 197
   public static function alphanumeric(string $s) : bool {
198 198
     return ctype_alnum(self::remove_spaces($s));
199 199
   }
@@ -205,7 +205,7 @@  discard block
 block discarded – undo
205 205
    * @param string $s: Cadena de texto a verificar
206 206
    *
207 207
    * @return bool, verdadero si sólamente tiene letras, falso si no
208
-  */
208
+   */
209 209
   public static function only_letters(string $s) : bool {
210 210
     return ctype_alpha(self::remove_spaces($s));
211 211
   }
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
    * @param string $url: Cadena de texto a convertir
230 230
    *
231 231
    * @return string Cadena de texto con formato de url amigable
232
-  */
232
+   */
233 233
   public static function url_amigable(string $url) : string {
234 234
     $url = str_replace(['á', 'é', 'í', 'ó', 'ú', 'ñ'], ['a', 'e', 'i', 'o', 'u', 'n'], $url);
235 235
     $url = str_replace([' ', '&', '\r\n', '\n', '+', '%'], '-', $url);
@@ -369,7 +369,7 @@  discard block
 block discarded – undo
369 369
    * Identificador único para la extensión de twig
370 370
    *
371 371
    * @return string Nombre de la extensión
372
-  */
372
+   */
373 373
   public function getName() : string {
374 374
     return 'ocrend_framework_helper_strings';
375 375
   }
Please login to merge, or discard this patch.
Spacing   +13 added lines, -13 removed lines patch added patch discarded remove patch
@@ -29,25 +29,25 @@  discard block
 block discarded – undo
29 29
   */
30 30
   public static function amigable_time(int $from, $to = null) : string {   
31 31
     $intervalos = ['segundo', 'minuto', 'hora', 'día', 'semana', 'mes', 'año'];
32
-    $duraciones = ['60','60','24','7','4.35','12'];
32
+    $duraciones = ['60', '60', '24', '7', '4.35', '12'];
33 33
     $to = $to ?? time();
34 34
 
35 35
     $diferencia = $from - $to;
36 36
     $tiempo = 'Dentro de';
37
-    if($to > $from) {   
37
+    if ($to > $from) {   
38 38
         $diferencia = $to - $from;
39 39
         $tiempo = 'Hace';
40 40
     }
41 41
     
42
-    for($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1 ; $j++) {
42
+    for ($j = 0; $diferencia >= $duraciones[$j] && $j < sizeof($duraciones) - 1; $j++) {
43 43
       $diferencia /= $duraciones[$j];
44 44
     }
45 45
     
46 46
     $diferencia = round($diferencia);
47 47
     
48
-    if($diferencia != 1) {
49
-      $intervalos[5].= 'e'; //MESES
50
-      $intervalos[$j].= 's';
48
+    if ($diferencia != 1) {
49
+      $intervalos[5] .= 'e'; //MESES
50
+      $intervalos[$j] .= 's';
51 51
     }
52 52
    
53 53
     return $tiempo . ' ' . $diferencia . ' ' . $intervalos[$j];
@@ -102,8 +102,8 @@  discard block
 block discarded – undo
102 102
    * @return string : Texto desencriptado
103 103
    */
104 104
   public static function ocrend_decode(string $str, string $key) : string {
105
-    $data = base64_decode($str );
106
-    $___s___  = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
105
+    $data = base64_decode($str);
106
+    $___s___ = substr($data, 0, mcrypt_get_iv_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC));
107 107
     return rtrim(
108 108
         mcrypt_decrypt(
109 109
             MCRYPT_RIJNDAEL_128,
@@ -137,9 +137,9 @@  discard block
 block discarded – undo
137 137
    *
138 138
    */
139 139
   public static function date_difference(string $ini, string $fin) : int {
140
-    $ini_i = explode('-',str_replace('/','-',$ini));
141
-    $fin_i = explode('-',str_replace('/','-',$fin));
142
-    return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2])) / 86400);
140
+    $ini_i = explode('-', str_replace('/', '-', $ini));
141
+    $fin_i = explode('-', str_replace('/', '-', $fin));
142
+    return (int) floor((mktime(0, 0, 0, $fin_i[1], $fin_i[0], $fin_i[2]) - mktime(0, 0, 0, $ini_i[1], $ini_i[0], $ini_i[2]))/86400);
143 143
   }
144 144
 
145 145
   /**
@@ -162,7 +162,7 @@  discard block
 block discarded – undo
162 162
    *
163 163
    */
164 164
   public static function days_of_month() : int {
165
-    return cal_days_in_month(CAL_GREGORIAN, (int) date('m',time()), (int) date('Y',time()));
165
+    return cal_days_in_month(CAL_GREGORIAN, (int) date('m', time()), (int) date('Y', time()));
166 166
   }
167 167
 
168 168
   /**
@@ -335,7 +335,7 @@  discard block
 block discarded – undo
335 335
    * @return int Cantidad de palabras
336 336
    */
337 337
   public static function count_words(string $s) : int {
338
-    return (int) str_word_count($s,0,'0..9_');
338
+    return (int) str_word_count($s, 0, '0..9_');
339 339
   }
340 340
 
341 341
   /**
Please login to merge, or discard this patch.
Ocrend/Kernel/Controllers/Controllers.php 2 patches
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -25,57 +25,57 @@
 block discarded – undo
25 25
 abstract class Controllers {
26 26
     
27 27
     /**
28
-      * Obtiene el objeto del template 
29
-      *
30
-      * @var \Twig_Environment
31
-    */
28
+     * Obtiene el objeto del template 
29
+     *
30
+     * @var \Twig_Environment
31
+     */
32 32
     protected $template;
33 33
 
34 34
     /**
35
-      * Verifica si está definida la ruta /id como un integer >= 1
36
-      *
37
-      * @var bool
38
-    */
35
+     * Verifica si está definida la ruta /id como un integer >= 1
36
+     *
37
+     * @var bool
38
+     */
39 39
     protected $isset_id = false;
40 40
 
41 41
     /**
42
-      * Tiene el valor de la ruta /método
43
-      *
44
-      * @var string|null
45
-    */
42
+     * Tiene el valor de la ruta /método
43
+     *
44
+     * @var string|null
45
+     */
46 46
     protected $method;
47 47
     
48 48
     /**
49
-      * Arreglo con la información del usuario conectado actualmente.
50
-      *
51
-      * @var array 
52
-    */
49
+     * Arreglo con la información del usuario conectado actualmente.
50
+     *
51
+     * @var array 
52
+     */
53 53
     protected $user = array();
54 54
 
55 55
     /**
56
-      * Contiene información sobre el estado del usuario, si está o no conectado.
57
-      *
58
-      * @var bool
59
-    */
56
+     * Contiene información sobre el estado del usuario, si está o no conectado.
57
+     *
58
+     * @var bool
59
+     */
60 60
     private $is_logged = false;
61 61
 
62 62
     /** 
63
-      * Parámetros de configuración para el controlador con la forma:
64
-      * 'parmáetro' => (bool) valor
65
-      *
66
-      * @var array
67
-    */
63
+     * Parámetros de configuración para el controlador con la forma:
64
+     * 'parmáetro' => (bool) valor
65
+     *
66
+     * @var array
67
+     */
68 68
     private $controllerConfig;
69 69
 
70 70
     /**
71
-      * Configuración inicial de cualquier controlador
72
-      *
73
-      * @param IRouter $router: Instancia de un Router
74
-      * @param array $configController: Arreglo de configuración con la forma  
75
-      *     'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados
76
-      *     'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados)
77
-      *
78
-    */
71
+     * Configuración inicial de cualquier controlador
72
+     *
73
+     * @param IRouter $router: Instancia de un Router
74
+     * @param array $configController: Arreglo de configuración con la forma  
75
+     *     'users_logged' => bool, # Configura el controlador para solo ser visto por usuarios logeados
76
+     *     'users_not_logged' => bool, # Configura el controlador para solo ser visto por !(usuarios logeados)
77
+     *
78
+     */
79 79
     protected function __construct(IRouter $router, $configController = []) {
80 80
         global $config, $http, $session, $cookie;
81 81
 
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -119,7 +119,7 @@
 block discarded – undo
119 119
         $this->template->addExtension(new Helper\Functions);
120 120
 
121 121
         # Debug disponible en twig
122
-        if(!$config['build']['production']) {
122
+        if (!$config['build']['production']) {
123 123
           $this->template->addExtension(new \Twig_Extension_Debug());
124 124
         }
125 125
 
Please login to merge, or discard this patch.
api/index.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -48,12 +48,12 @@
 block discarded – undo
48 48
 }
49 49
 
50 50
 # Arrancar
51
-if($config['build']['production']) {
51
+if ($config['build']['production']) {
52 52
     try { 
53 53
         ___loadApi();  
54
-    } catch(\Throwable $e) {
54
+    } catch (\Throwable $e) {
55 55
         ___catchApi();
56
-    } catch(\Exception $e) {
56
+    } catch (\Exception $e) {
57 57
         ___catchApi();
58 58
     }
59 59
 } else {
Please login to merge, or discard this patch.
api/controllers/ini.app.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -18,12 +18,12 @@  discard block
 block discarded – undo
18 18
 /**
19 19
  * Convertir esta api en RESTFULL para recibir JSON
20 20
  */
21
-$app->before(function () use ($app) {
21
+$app->before(function() use ($app) {
22 22
     try {
23 23
         global $config, $http;
24 24
         
25 25
         # Verificar si la api no está activa
26
-        if(!$config['api']['active']) {
26
+        if (!$config['api']['active']) {
27 27
             throw new ModelsException('Servicio inactivo');
28 28
         }
29 29
 
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
             $data = json_decode($http->getContent(), true);
33 33
             $http->request->replace(is_array($data) ? $data : array());
34 34
         }
35
-    } catch(ModelsException $e) {
35
+    } catch (ModelsException $e) {
36 36
         return $app->json(array(
37 37
             'success' => 0,
38 38
             'message' => $e->getMessage()
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
 /**
44 44
  * Servidores autorizados para consumir la api.
45 45
  */
46
-$app->after(function (Request $request, Response $response) {
46
+$app->after(function(Request $request, Response $response) {
47 47
     global $config;
48 48
 
49 49
     $response->headers->set('Access-Control-Allow-Origin', $config['api']['origin']);
Please login to merge, or discard this patch.
api/controllers/post.controllers.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -12,9 +12,9 @@  discard block
 block discarded – undo
12 12
 use app\models as Model;
13 13
 
14 14
 /**
15
-    * Inicio de sesión
16
-    *
17
-    * @return json
15
+ * Inicio de sesión
16
+ *
17
+ * @return json
18 18
 */  
19 19
 $app->post('/login', function() use($app) {
20 20
     $u = new Model\Users;   
@@ -23,9 +23,9 @@  discard block
 block discarded – undo
23 23
 });
24 24
 
25 25
 /**
26
-    * Registro de un usuario
27
-    *
28
-    * @return json
26
+ * Registro de un usuario
27
+ *
28
+ * @return json
29 29
 */
30 30
 $app->post('/register', function() use($app) {
31 31
     $u = new Model\Users; 
@@ -34,9 +34,9 @@  discard block
 block discarded – undo
34 34
 });
35 35
 
36 36
 /**
37
-    * Recuperar contraseña perdida
38
-    *
39
-    * @return json
37
+ * Recuperar contraseña perdida
38
+ *
39
+ * @return json
40 40
 */
41 41
 $app->post('/lostpass', function() use($app) {
42 42
     $u = new Model\Users; 
Please login to merge, or discard this patch.