@@ -19,7 +19,9 @@ discard block |
||
| 19 | 19 | |
| 20 | 20 | public function needsRehash($hash = null) |
| 21 | 21 | { |
| 22 | - if (is_null($hash)) $hash = $this->value; |
|
| 22 | + if (is_null($hash)) { |
|
| 23 | + $hash = $this->value; |
|
| 24 | + } |
|
| 23 | 25 | |
| 24 | 26 | return password_needs_rehash($hash, PASSWORD_BCRYPT, ['cost' => 10]); |
| 25 | 27 | } |
@@ -57,7 +59,9 @@ discard block |
||
| 57 | 59 | |
| 58 | 60 | public function setValuesFromModel($model) |
| 59 | 61 | { |
| 60 | - if (property_exists($model, $this->name)) $this->value = $model->{$this->name}; |
|
| 62 | + if (property_exists($model, $this->name)) { |
|
| 63 | + $this->value = $model->{$this->name}; |
|
| 64 | + } |
|
| 61 | 65 | } |
| 62 | 66 | |
| 63 | 67 | public function setValuesFromRequest($request) |
@@ -67,7 +71,9 @@ discard block |
||
| 67 | 71 | |
| 68 | 72 | public function fillModelWithValues($model) |
| 69 | 73 | { |
| 70 | - if (property_exists($model, $this->name)) $model->{$this->name} = $this->value; |
|
| 74 | + if (property_exists($model, $this->name)) { |
|
| 75 | + $model->{$this->name} = $this->value; |
|
| 76 | + } |
|
| 71 | 77 | } |
| 72 | 78 | |
| 73 | 79 | public function validateRequired() |
@@ -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 |
@@ -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 | } |
@@ -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 |
@@ -7,26 +7,26 @@ |
||
| 7 | 7 | |
| 8 | 8 | class Laravel implements Request { |
| 9 | 9 | |
| 10 | - protected $request; |
|
| 11 | - |
|
| 12 | - public function __construct(IlluminateRequest $request) |
|
| 13 | - { |
|
| 14 | - $this->request = $request; |
|
| 15 | - } |
|
| 16 | - |
|
| 17 | - public function all() |
|
| 18 | - { |
|
| 19 | - return $this->request->all(); |
|
| 20 | - } |
|
| 21 | - |
|
| 22 | - public function get($key) |
|
| 23 | - { |
|
| 24 | - return $this->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(IlluminateRequest $request) |
|
| 13 | + { |
|
| 14 | + $this->request = $request; |
|
| 15 | + } |
|
| 16 | + |
|
| 17 | + public function all() |
|
| 18 | + { |
|
| 19 | + return $this->request->all(); |
|
| 20 | + } |
|
| 21 | + |
|
| 22 | + public function get($key) |
|
| 23 | + { |
|
| 24 | + return $this->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 |
@@ -357,7 +357,7 @@ discard block |
||
| 357 | 357 | */ |
| 358 | 358 | public function completed($name = null) |
| 359 | 359 | { |
| 360 | - if($this->submitted($name) && $this->valid()) { |
|
| 360 | + if ($this->submitted($name) && $this->valid()) { |
|
| 361 | 361 | $this->broadcast('completed'); |
| 362 | 362 | return true; |
| 363 | 363 | } |
@@ -497,7 +497,7 @@ discard block |
||
| 497 | 497 | $errors = []; |
| 498 | 498 | |
| 499 | 499 | foreach ($this->fields as $field) { |
| 500 | - foreach($field->errors() as $error) { |
|
| 500 | + foreach ($field->errors() as $error) { |
|
| 501 | 501 | $errors[] = $error; |
| 502 | 502 | } |
| 503 | 503 | } |
@@ -619,8 +619,8 @@ discard block |
||
| 619 | 619 | { |
| 620 | 620 | $config = $this->templateConfig($template); |
| 621 | 621 | |
| 622 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 623 | - foreach($config['plugins'] as $plugin) { |
|
| 622 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 623 | + foreach ($config['plugins'] as $plugin) { |
|
| 624 | 624 | $this->addPlugin($plugin); |
| 625 | 625 | } |
| 626 | 626 | } |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | { |
| 637 | 637 | $config = $this->templateConfig($template); |
| 638 | 638 | |
| 639 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 640 | - foreach($config['plugins'] as $plugin) { |
|
| 639 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 640 | + foreach ($config['plugins'] as $plugin) { |
|
| 641 | 641 | $this->removePlugin($plugin); |
| 642 | 642 | } |
| 643 | 643 | } |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | foreach ($field->errors() as $error => $parameters) { |
| 675 | 675 | |
| 676 | 676 | if ($error == 'userDefined') { |
| 677 | - foreach($parameters as $message) { |
|
| 677 | + foreach ($parameters as $message) { |
|
| 678 | 678 | $properties['errors'][] = ['error' => $message]; |
| 679 | 679 | } |
| 680 | 680 | } else { |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $message = $this->translate($error, $field); |
| 685 | 685 | |
| 686 | - foreach($parameters as $key => $value) { |
|
| 686 | + foreach ($parameters as $key => $value) { |
|
| 687 | 687 | if (is_object($value) && method_exists($value, '__toString')) $value = (string) $value; |
| 688 | 688 | if (is_array($value)) $value = implode(', ', $value); |
| 689 | 689 | $message = str_replace('['.$key.']', $value, $message); |
@@ -930,7 +930,7 @@ discard block |
||
| 930 | 930 | */ |
| 931 | 931 | private function broadcast($event, $params = []) |
| 932 | 932 | { |
| 933 | - foreach($this->plugins as $plugin) { |
|
| 933 | + foreach ($this->plugins as $plugin) { |
|
| 934 | 934 | $plugin->event($this, $event, $params); |
| 935 | 935 | } |
| 936 | 936 | } |
@@ -1078,7 +1078,7 @@ discard block |
||
| 1078 | 1078 | { |
| 1079 | 1079 | if ( ! method_exists($this, $method)) |
| 1080 | 1080 | { |
| 1081 | - if ( $this->typeExists($method)) { |
|
| 1081 | + if ($this->typeExists($method)) { |
|
| 1082 | 1082 | return $this->addField($method, array_shift($parameters)); |
| 1083 | 1083 | } |
| 1084 | 1084 | } |
@@ -253,7 +253,9 @@ discard block |
||
| 253 | 253 | */ |
| 254 | 254 | public function fields($names = null) |
| 255 | 255 | { |
| 256 | - if (is_null($names)) return $this->fields; |
|
| 256 | + if (is_null($names)) { |
|
| 257 | + return $this->fields; |
|
| 258 | + } |
|
| 257 | 259 | |
| 258 | 260 | return array_filter($this->fields, function($field) use ($names) { |
| 259 | 261 | return array_key_exists($field->name, $names); |
@@ -473,7 +475,9 @@ discard block |
||
| 473 | 475 | $class = '\\Fields\\'.ucwords($class).'\\'.ucwords($class); |
| 474 | 476 | |
| 475 | 477 | foreach ($this->namespaces as $namespace) { |
| 476 | - if (class_exists($namespace.$class)) return $namespace.$class; |
|
| 478 | + if (class_exists($namespace.$class)) { |
|
| 479 | + return $namespace.$class; |
|
| 480 | + } |
|
| 477 | 481 | } |
| 478 | 482 | } |
| 479 | 483 | |
@@ -486,9 +490,13 @@ discard block |
||
| 486 | 490 | */ |
| 487 | 491 | public function errors($name = null) |
| 488 | 492 | { |
| 489 | - if ($this->submitted()) $this->validate(); |
|
| 493 | + if ($this->submitted()) { |
|
| 494 | + $this->validate(); |
|
| 495 | + } |
|
| 490 | 496 | |
| 491 | - if ( ! is_null($name)) return $this->field($name)->errors(); |
|
| 497 | + if ( ! is_null($name)) { |
|
| 498 | + return $this->field($name)->errors(); |
|
| 499 | + } |
|
| 492 | 500 | |
| 493 | 501 | $errors = []; |
| 494 | 502 | |
@@ -680,8 +688,12 @@ discard block |
||
| 680 | 688 | $message = $this->translate($error, $field); |
| 681 | 689 | |
| 682 | 690 | foreach($parameters as $key => $value) { |
| 683 | - if (is_object($value) && method_exists($value, '__toString')) $value = (string) $value; |
|
| 684 | - if (is_array($value)) $value = implode(', ', $value); |
|
| 691 | + if (is_object($value) && method_exists($value, '__toString')) { |
|
| 692 | + $value = (string) $value; |
|
| 693 | + } |
|
| 694 | + if (is_array($value)) { |
|
| 695 | + $value = implode(', ', $value); |
|
| 696 | + } |
|
| 685 | 697 | $message = str_replace('['.$key.']', $value, $message); |
| 686 | 698 | } |
| 687 | 699 | $properties['errors'][] = ['error' => $message]; |
@@ -701,7 +713,9 @@ discard block |
||
| 701 | 713 | */ |
| 702 | 714 | public function renderField($field, $properties = null) |
| 703 | 715 | { |
| 704 | - if (is_null($properties)) $properties = $this->fieldProperties($field); |
|
| 716 | + if (is_null($properties)) { |
|
| 717 | + $properties = $this->fieldProperties($field); |
|
| 718 | + } |
|
| 705 | 719 | |
| 706 | 720 | return $this->renderTemplate($field->type, $properties, $field); |
| 707 | 721 | } |
@@ -715,7 +729,9 @@ discard block |
||
| 715 | 729 | */ |
| 716 | 730 | public function renderFieldErrors($field, $properties = null) |
| 717 | 731 | { |
| 718 | - if (is_null($properties)) $properties = $this->fieldProperties($field); |
|
| 732 | + if (is_null($properties)) { |
|
| 733 | + $properties = $this->fieldProperties($field); |
|
| 734 | + } |
|
| 719 | 735 | |
| 720 | 736 | return $this->renderTemplate('errors', $properties, $field); |
| 721 | 737 | } |
@@ -732,9 +748,13 @@ discard block |
||
| 732 | 748 | |
| 733 | 749 | $this->setValues(); |
| 734 | 750 | |
| 735 | - if ($this->submitted()) $this->validate(); |
|
| 751 | + if ($this->submitted()) { |
|
| 752 | + $this->validate(); |
|
| 753 | + } |
|
| 736 | 754 | |
| 737 | - if ( ! is_null($template)) $this->setTemplate($template); |
|
| 755 | + if ( ! is_null($template)) { |
|
| 756 | + $this->setTemplate($template); |
|
| 757 | + } |
|
| 738 | 758 | |
| 739 | 759 | $properties = []; |
| 740 | 760 | $properties['id'] = $this->id; |