@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'placeholder' => 'Buscar…', |
|
| 5 | - 'button' => 'Ir', |
|
| 4 | + 'placeholder' => 'Buscar…', |
|
| 5 | + 'button' => 'Ir', |
|
| 6 | 6 | ]; |
| 7 | 7 | \ No newline at end of file |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | return [ |
| 4 | - 'placeholder' => 'Search…', |
|
| 5 | - 'button' => 'Go', |
|
| 4 | + 'placeholder' => 'Search…', |
|
| 5 | + 'button' => 'Go', |
|
| 6 | 6 | ]; |
| 7 | 7 | \ No newline at end of file |
@@ -25,12 +25,16 @@ discard block |
||
| 25 | 25 | |
| 26 | 26 | public function setValuesFromDefaults($defaults) |
| 27 | 27 | { |
| 28 | - if (count($defaults)) $this->value = array_shift($defaults); |
|
| 28 | + if (count($defaults)) { |
|
| 29 | + $this->value = array_shift($defaults); |
|
| 30 | + } |
|
| 29 | 31 | } |
| 30 | 32 | |
| 31 | 33 | public function setValuesFromModel($model) |
| 32 | 34 | { |
| 33 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 35 | + if (property_exists($model, $this->name)) { |
|
| 36 | + $this->value = $model->{$this->name}; |
|
| 37 | + } |
|
| 34 | 38 | } |
| 35 | 39 | |
| 36 | 40 | public function setValuesFromRequest($request) |
@@ -40,7 +44,9 @@ discard block |
||
| 40 | 44 | |
| 41 | 45 | public function fillModelWithValues($model) |
| 42 | 46 | { |
| 43 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 47 | + if (property_exists($model, $this->name)) { |
|
| 48 | + $model->{$this->name} = $this->value; |
|
| 49 | + } |
|
| 44 | 50 | } |
| 45 | 51 | |
| 46 | 52 | public function validateRequired() |
@@ -4,87 +4,87 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Validator { |
| 6 | 6 | |
| 7 | - public function required($var) |
|
| 8 | - { |
|
| 9 | - if (is_null($var)) return false; |
|
| 7 | + public function required($var) |
|
| 8 | + { |
|
| 9 | + if (is_null($var)) return false; |
|
| 10 | 10 | else if (is_string($var) && trim($var) === '') return false; |
| 11 | 11 | return true; |
| 12 | - } |
|
| 13 | - |
|
| 14 | - public function stringMin($var, $min) |
|
| 15 | - { |
|
| 16 | - return strlen($var) >= $min; |
|
| 17 | - } |
|
| 18 | - |
|
| 19 | - public function stringMax($var, $max) |
|
| 20 | - { |
|
| 21 | - return strlen($var) <= $max; |
|
| 22 | - } |
|
| 23 | - |
|
| 24 | - public function alpha($var) |
|
| 25 | - { |
|
| 26 | - return is_string($var) && preg_match('/^[\pL\pM]+$/u', $var); |
|
| 27 | - } |
|
| 28 | - |
|
| 29 | - public function alphaNum($var) |
|
| 30 | - { |
|
| 31 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 12 | + } |
|
| 13 | + |
|
| 14 | + public function stringMin($var, $min) |
|
| 15 | + { |
|
| 16 | + return strlen($var) >= $min; |
|
| 17 | + } |
|
| 18 | + |
|
| 19 | + public function stringMax($var, $max) |
|
| 20 | + { |
|
| 21 | + return strlen($var) <= $max; |
|
| 22 | + } |
|
| 23 | + |
|
| 24 | + public function alpha($var) |
|
| 25 | + { |
|
| 26 | + return is_string($var) && preg_match('/^[\pL\pM]+$/u', $var); |
|
| 27 | + } |
|
| 28 | + |
|
| 29 | + public function alphaNum($var) |
|
| 30 | + { |
|
| 31 | + if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 32 | 32 | return preg_match('/^[\pL\pM\pN]+$/u', $var); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | - public function alphaDash($var) |
|
| 36 | - { |
|
| 37 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 35 | + public function alphaDash($var) |
|
| 36 | + { |
|
| 37 | + if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 38 | 38 | return preg_match('/^[\pL\pM\pN_-]+$/u', $var); |
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function in($var, $array) |
|
| 42 | - { |
|
| 43 | - return in_array($var, $array); |
|
| 44 | - } |
|
| 45 | - |
|
| 46 | - public function notIn($var, $array) |
|
| 47 | - { |
|
| 48 | - return ! in_array($var, $array); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - public function email($var) |
|
| 52 | - { |
|
| 53 | - return filter_var($var, FILTER_VALIDATE_EMAIL) !== false; |
|
| 54 | - } |
|
| 55 | - |
|
| 56 | - public function numeric($var) |
|
| 57 | - { |
|
| 58 | - return is_numeric($var); |
|
| 59 | - } |
|
| 60 | - |
|
| 61 | - public function numericMin($var, $min) |
|
| 62 | - { |
|
| 63 | - return $var >= $min; |
|
| 64 | - } |
|
| 65 | - |
|
| 66 | - public function numericMax($var, $max) |
|
| 67 | - { |
|
| 68 | - return $var <= $max; |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - public function integer($var) |
|
| 72 | - { |
|
| 73 | - return filter_var($var, FILTER_VALIDATE_INT) !== false; |
|
| 74 | - } |
|
| 75 | - |
|
| 76 | - public function snake($var) |
|
| 77 | - { |
|
| 78 | - if ( ! ctype_lower($var)) { |
|
| 79 | - $var = preg_replace('/\s+/', '', $var); |
|
| 80 | - $var = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.'_', $var)); |
|
| 81 | - } |
|
| 82 | - return $var; |
|
| 83 | - } |
|
| 84 | - |
|
| 85 | - public function studly($var) |
|
| 86 | - { |
|
| 87 | - return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $var))); |
|
| 88 | - } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function in($var, $array) |
|
| 42 | + { |
|
| 43 | + return in_array($var, $array); |
|
| 44 | + } |
|
| 45 | + |
|
| 46 | + public function notIn($var, $array) |
|
| 47 | + { |
|
| 48 | + return ! in_array($var, $array); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + public function email($var) |
|
| 52 | + { |
|
| 53 | + return filter_var($var, FILTER_VALIDATE_EMAIL) !== false; |
|
| 54 | + } |
|
| 55 | + |
|
| 56 | + public function numeric($var) |
|
| 57 | + { |
|
| 58 | + return is_numeric($var); |
|
| 59 | + } |
|
| 60 | + |
|
| 61 | + public function numericMin($var, $min) |
|
| 62 | + { |
|
| 63 | + return $var >= $min; |
|
| 64 | + } |
|
| 65 | + |
|
| 66 | + public function numericMax($var, $max) |
|
| 67 | + { |
|
| 68 | + return $var <= $max; |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + public function integer($var) |
|
| 72 | + { |
|
| 73 | + return filter_var($var, FILTER_VALIDATE_INT) !== false; |
|
| 74 | + } |
|
| 75 | + |
|
| 76 | + public function snake($var) |
|
| 77 | + { |
|
| 78 | + if ( ! ctype_lower($var)) { |
|
| 79 | + $var = preg_replace('/\s+/', '', $var); |
|
| 80 | + $var = strtolower(preg_replace('/(.)(?=[A-Z])/', '$1'.'_', $var)); |
|
| 81 | + } |
|
| 82 | + return $var; |
|
| 83 | + } |
|
| 84 | + |
|
| 85 | + public function studly($var) |
|
| 86 | + { |
|
| 87 | + return str_replace(' ', '', ucwords(str_replace(['-', '_'], ' ', $var))); |
|
| 88 | + } |
|
| 89 | 89 | |
| 90 | 90 | } |
@@ -28,13 +28,13 @@ |
||
| 28 | 28 | |
| 29 | 29 | public function alphaNum($var) |
| 30 | 30 | { |
| 31 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 31 | + if ( ! is_string($var) && ! is_numeric($var)) return false; |
|
| 32 | 32 | return preg_match('/^[\pL\pM\pN]+$/u', $var); |
| 33 | 33 | } |
| 34 | 34 | |
| 35 | 35 | public function alphaDash($var) |
| 36 | 36 | { |
| 37 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 37 | + if ( ! is_string($var) && ! is_numeric($var)) return false; |
|
| 38 | 38 | return preg_match('/^[\pL\pM\pN_-]+$/u', $var); |
| 39 | 39 | } |
| 40 | 40 | |
@@ -6,8 +6,11 @@ discard block |
||
| 6 | 6 | |
| 7 | 7 | public function required($var) |
| 8 | 8 | { |
| 9 | - if (is_null($var)) return false; |
|
| 10 | - else if (is_string($var) && trim($var) === '') return false; |
|
| 9 | + if (is_null($var)) { |
|
| 10 | + return false; |
|
| 11 | + } else if (is_string($var) && trim($var) === '') { |
|
| 12 | + return false; |
|
| 13 | + } |
|
| 11 | 14 | return true; |
| 12 | 15 | } |
| 13 | 16 | |
@@ -28,13 +31,17 @@ discard block |
||
| 28 | 31 | |
| 29 | 32 | public function alphaNum($var) |
| 30 | 33 | { |
| 31 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 34 | + if (! is_string($var) && ! is_numeric($var)) { |
|
| 35 | + return false; |
|
| 36 | + } |
|
| 32 | 37 | return preg_match('/^[\pL\pM\pN]+$/u', $var); |
| 33 | 38 | } |
| 34 | 39 | |
| 35 | 40 | public function alphaDash($var) |
| 36 | 41 | { |
| 37 | - if (! is_string($var) && ! is_numeric($var)) return false; |
|
| 42 | + if (! is_string($var) && ! is_numeric($var)) { |
|
| 43 | + return false; |
|
| 44 | + } |
|
| 38 | 45 | return preg_match('/^[\pL\pM\pN_-]+$/u', $var); |
| 39 | 46 | } |
| 40 | 47 | |
@@ -6,18 +6,18 @@ |
||
| 6 | 6 | |
| 7 | 7 | class Blade implements Engine { |
| 8 | 8 | |
| 9 | - /** |
|
| 9 | + /** |
|
| 10 | 10 | * Render the template content. |
| 11 | 11 | * |
| 12 | - * @param string $path |
|
| 13 | - * @param array $properties |
|
| 12 | + * @param string $path |
|
| 13 | + * @param array $properties |
|
| 14 | 14 | * @return string |
| 15 | 15 | */ |
| 16 | - public function render($path, $properties = []) |
|
| 17 | - { |
|
| 18 | - if ( ! function_exists('app')) throw new \Exception('Laravel required for blade rendering engine.'); |
|
| 16 | + public function render($path, $properties = []) |
|
| 17 | + { |
|
| 18 | + if ( ! function_exists('app')) throw new \Exception('Laravel required for blade rendering engine.'); |
|
| 19 | 19 | |
| 20 | - return app()->make('view')->file($path, $properties); |
|
| 21 | - } |
|
| 20 | + return app()->make('view')->file($path, $properties); |
|
| 21 | + } |
|
| 22 | 22 | |
| 23 | 23 | } |
@@ -15,7 +15,9 @@ |
||
| 15 | 15 | */ |
| 16 | 16 | public function render($path, $properties = []) |
| 17 | 17 | { |
| 18 | - if ( ! function_exists('app')) throw new \Exception('Laravel required for blade rendering engine.'); |
|
| 18 | + if ( ! function_exists('app')) { |
|
| 19 | + throw new \Exception('Laravel required for blade rendering engine.'); |
|
| 20 | + } |
|
| 19 | 21 | |
| 20 | 22 | return app()->make('view')->file($path, $properties); |
| 21 | 23 | } |
@@ -12,32 +12,32 @@ |
||
| 12 | 12 | * |
| 13 | 13 | * @var \Mustache_Engine |
| 14 | 14 | */ |
| 15 | - protected $compiler; |
|
| 15 | + protected $compiler; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Fetch the compiler. |
| 19 | 19 | * |
| 20 | 20 | * @return \Mustache_Engine |
| 21 | 21 | */ |
| 22 | - public function compiler() |
|
| 23 | - { |
|
| 24 | - if ( ! $this->compiler) $this->compiler = new Mustache_Engine; |
|
| 22 | + public function compiler() |
|
| 23 | + { |
|
| 24 | + if ( ! $this->compiler) $this->compiler = new Mustache_Engine; |
|
| 25 | 25 | |
| 26 | - return $this->compiler; |
|
| 27 | - } |
|
| 26 | + return $this->compiler; |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - /** |
|
| 29 | + /** |
|
| 30 | 30 | * Render the template content. |
| 31 | 31 | * |
| 32 | - * @param string $path |
|
| 33 | - * @param array $properties |
|
| 32 | + * @param string $path |
|
| 33 | + * @param array $properties |
|
| 34 | 34 | * @return string |
| 35 | 35 | */ |
| 36 | - public function render($path, $properties = []) |
|
| 37 | - { |
|
| 38 | - $content = file_get_contents($path); |
|
| 36 | + public function render($path, $properties = []) |
|
| 37 | + { |
|
| 38 | + $content = file_get_contents($path); |
|
| 39 | 39 | |
| 40 | - return $this->compiler()->render($content, $properties); |
|
| 41 | - } |
|
| 40 | + return $this->compiler()->render($content, $properties); |
|
| 41 | + } |
|
| 42 | 42 | |
| 43 | 43 | } |
@@ -21,7 +21,9 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | public function compiler() |
| 23 | 23 | { |
| 24 | - if ( ! $this->compiler) $this->compiler = new Mustache_Engine; |
|
| 24 | + if ( ! $this->compiler) { |
|
| 25 | + $this->compiler = new Mustache_Engine; |
|
| 26 | + } |
|
| 25 | 27 | |
| 26 | 28 | return $this->compiler; |
| 27 | 29 | } |
@@ -8,39 +8,39 @@ |
||
| 8 | 8 | |
| 9 | 9 | class Twig implements Engine { |
| 10 | 10 | |
| 11 | - /** |
|
| 12 | - * The twig compiler engine. |
|
| 13 | - * |
|
| 14 | - * @var \Twig_Environment |
|
| 15 | - */ |
|
| 16 | - protected $compiler; |
|
| 17 | - |
|
| 18 | - /** |
|
| 11 | + /** |
|
| 12 | + * The twig compiler engine. |
|
| 13 | + * |
|
| 14 | + * @var \Twig_Environment |
|
| 15 | + */ |
|
| 16 | + protected $compiler; |
|
| 17 | + |
|
| 18 | + /** |
|
| 19 | 19 | * Fetch the compiler. |
| 20 | 20 | * |
| 21 | 21 | * @return \Twig_Environment |
| 22 | 22 | */ |
| 23 | - public function compiler() |
|
| 24 | - { |
|
| 25 | - if ( ! $this->compiler) { |
|
| 26 | - $this->compiler = new Twig_Environment(new Twig_Loader_String); |
|
| 27 | - } |
|
| 23 | + public function compiler() |
|
| 24 | + { |
|
| 25 | + if ( ! $this->compiler) { |
|
| 26 | + $this->compiler = new Twig_Environment(new Twig_Loader_String); |
|
| 27 | + } |
|
| 28 | 28 | |
| 29 | - return $this->compiler; |
|
| 30 | - } |
|
| 29 | + return $this->compiler; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | - /** |
|
| 32 | + /** |
|
| 33 | 33 | * Render the template content. |
| 34 | 34 | * |
| 35 | - * @param string $path |
|
| 36 | - * @param array $properties |
|
| 35 | + * @param string $path |
|
| 36 | + * @param array $properties |
|
| 37 | 37 | * @return string |
| 38 | 38 | */ |
| 39 | - public function render($path, $properties = []) |
|
| 40 | - { |
|
| 41 | - $content = file_get_contents($path); |
|
| 39 | + public function render($path, $properties = []) |
|
| 40 | + { |
|
| 41 | + $content = file_get_contents($path); |
|
| 42 | 42 | |
| 43 | - return $this->compiler()->render($content, $properties); |
|
| 44 | - } |
|
| 43 | + return $this->compiler()->render($content, $properties); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | 46 | } |
@@ -4,13 +4,13 @@ |
||
| 4 | 4 | |
| 5 | 5 | interface Engine { |
| 6 | 6 | |
| 7 | - /** |
|
| 7 | + /** |
|
| 8 | 8 | * Render the template content. |
| 9 | 9 | * |
| 10 | - * @param string $path |
|
| 11 | - * @param array $properties |
|
| 10 | + * @param string $path |
|
| 11 | + * @param array $properties |
|
| 12 | 12 | * @return string |
| 13 | 13 | */ |
| 14 | - public function render($path, $properties = []); |
|
| 14 | + public function render($path, $properties = []); |
|
| 15 | 15 | |
| 16 | 16 | } |
| 17 | 17 | \ No newline at end of file |
@@ -7,26 +7,26 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Symfony implements Request { |
| 9 | 9 | |
| 10 | - protected $request; |
|
| 11 | - |
|
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - $this->request = SymfonyRequest::createFromGlobals(); |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function all() |
|
| 18 | - { |
|
| 19 | - return $this->request->request->all(); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function get($key) |
|
| 23 | - { |
|
| 24 | - return $this->request->request->get($key); |
|
| 25 | - } |
|
| 26 | - |
|
| 27 | - public function csrf() |
|
| 28 | - { |
|
| 29 | - return ['name' => '_token', 'value' => csrf_token()]; |
|
| 30 | - } |
|
| 10 | + protected $request; |
|
| 11 | + |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + $this->request = SymfonyRequest::createFromGlobals(); |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function all() |
|
| 18 | + { |
|
| 19 | + return $this->request->request->all(); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function get($key) |
|
| 23 | + { |
|
| 24 | + return $this->request->request->get($key); |
|
| 25 | + } |
|
| 26 | + |
|
| 27 | + public function csrf() |
|
| 28 | + { |
|
| 29 | + return ['name' => '_token', 'value' => csrf_token()]; |
|
| 30 | + } |
|
| 31 | 31 | |
| 32 | 32 | } |
| 33 | 33 | \ No newline at end of file |