@@ -28,7 +28,7 @@ discard block |
||
| 28 | 28 | */ |
| 29 | 29 | private function checkControllerExists(string $ctrlClass): void |
| 30 | 30 | { |
| 31 | - if (! class_exists($ctrlClass)) { |
|
| 31 | + if (!class_exists($ctrlClass)) { |
|
| 32 | 32 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
| 33 | 33 | } |
| 34 | 34 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | [$ctrlClass, $method] = $ctrlClass; |
| 46 | - if (! method_exists($ctrlClass, $method)) { |
|
| 47 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
| 46 | + if (!method_exists($ctrlClass, $method)) { |
|
| 47 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | |
@@ -57,13 +57,13 @@ discard block |
||
| 57 | 57 | // We decide to call data method on the widget object by default. |
| 58 | 58 | // If the user has explicitly declared controller class path on |
| 59 | 59 | // widget then we decide to call data method on that instead. |
| 60 | - if (! property_exists($widget, 'controller')) { |
|
| 60 | + if (!property_exists($widget, 'controller')) { |
|
| 61 | 61 | return method_exists($widget, 'data') ? [[$widget, 'data'], null] : [null, null]; |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | 64 | if (is_string($widget->controller)) { |
| 65 | - if (! str_contains($widget->controller, '@')) { |
|
| 66 | - return [$widget->controller.'@data', $widget->controller]; |
|
| 65 | + if (!str_contains($widget->controller, '@')) { |
|
| 66 | + return [$widget->controller . '@data', $widget->controller]; |
|
| 67 | 67 | } |
| 68 | 68 | $widget->controller = explode('@', $widget->controller); |
| 69 | 69 | } elseif (is_callable($widget->controller)) { |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | return app($widget); |
| 55 | 55 | } |
| 56 | 56 | |
| 57 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
| 57 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
| 58 | 58 | |
| 59 | 59 | return app($widget); |
| 60 | 60 | } |
@@ -70,13 +70,13 @@ discard block |
||
| 70 | 70 | private function generateHtml($widget, ...$args) |
| 71 | 71 | { |
| 72 | 72 | // Everything inside this function is executed only when the cache is not available. |
| 73 | - $expensivePhpCode = function () use ($widget, $args) { |
|
| 73 | + $expensivePhpCode = function() use ($widget, $args) { |
|
| 74 | 74 | $this->makeDataForView($widget, $args); |
| 75 | 75 | |
| 76 | 76 | return $this->renderTemplate($widget, ...$args); |
| 77 | 77 | }; |
| 78 | 78 | |
| 79 | - if (! $widget->cacheView) { |
|
| 79 | + if (!$widget->cacheView) { |
|
| 80 | 80 | return $expensivePhpCode(); |
| 81 | 81 | } |
| 82 | 82 | |
@@ -92,7 +92,7 @@ discard block |
||
| 92 | 92 | */ |
| 93 | 93 | private function makeDataForView($widget, array $args) |
| 94 | 94 | { |
| 95 | - $expensiveCode = function () use ($widget, $args) { |
|
| 95 | + $expensiveCode = function() use ($widget, $args) { |
|
| 96 | 96 | |
| 97 | 97 | // Here we call the data method on the widget class. |
| 98 | 98 | $viewData = isset($widget->controller) ? \App::call($widget->controller, ...$args) : []; |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | try { |
| 129 | 129 | $this->html = view($widget->template, $data)->render(); |
| 130 | 130 | } catch (\Throwable $t) { |
| 131 | - throw new \ErrorException('There was some error rendering '.get_class($widget).', template file: \''.$widget->template.'\' Error: '.$t->getMessage()); |
|
| 131 | + throw new \ErrorException('There was some error rendering ' . get_class($widget) . ', template file: \'' . $widget->template . '\' Error: ' . $t->getMessage()); |
|
| 132 | 132 | } |
| 133 | 133 | |
| 134 | 134 | // We try to minify the html before storing it in cache to save space. |