@@ -45,7 +45,7 @@ |
||
| 45 | 45 | private function _generateHtml($widget, ...$args) |
| 46 | 46 | { |
| 47 | 47 | // Everything inside this function is executed only when the cache is not available. |
| 48 | - $expensivePhpCode = function () use ($widget, $args) { |
|
| 48 | + $expensivePhpCode = function() use ($widget, $args) { |
|
| 49 | 49 | $this->_makeDataForView($widget, $args); |
| 50 | 50 | // render the template with the resulting data. |
| 51 | 51 | return $this->renderTemplate($widget); |
@@ -1,6 +1,6 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | -if (! function_exists('render_widget')) { |
|
| 3 | +if (!function_exists('render_widget')) { |
|
| 4 | 4 | function render_widget($widget, ...$args) |
| 5 | 5 | { |
| 6 | 6 | return app(\Imanghafoori\Widgets\Utils\WidgetRenderer::class)->renderWidget($widget, ...$args); |
@@ -19,7 +19,7 @@ discard block |
||
| 19 | 19 | // then we decide to call data method on that instead. |
| 20 | 20 | if (property_exists($widget, 'controller')) { |
| 21 | 21 | $ctrlClass = $widget->controller; |
| 22 | - $controllerMethod = ($ctrlClass).'@data'; |
|
| 22 | + $controllerMethod = ($ctrlClass) . '@data'; |
|
| 23 | 23 | } |
| 24 | 24 | |
| 25 | 25 | $this->checkControllerExists($ctrlClass); |
@@ -33,7 +33,7 @@ discard block |
||
| 33 | 33 | */ |
| 34 | 34 | private function checkControllerExists($ctrlClass) |
| 35 | 35 | { |
| 36 | - if (! class_exists($ctrlClass)) { |
|
| 36 | + if (!class_exists($ctrlClass)) { |
|
| 37 | 37 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
| 38 | 38 | } |
| 39 | 39 | } |
@@ -43,8 +43,8 @@ discard block |
||
| 43 | 43 | */ |
| 44 | 44 | private function checkDataMethodExists($ctrlClass) |
| 45 | 45 | { |
| 46 | - if (! method_exists($ctrlClass, 'data')) { |
|
| 47 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
| 46 | + if (!method_exists($ctrlClass, 'data')) { |
|
| 47 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
| 48 | 48 | } |
| 49 | 49 | } |
| 50 | 50 | } |
@@ -11,8 +11,8 @@ discard block |
||
| 11 | 11 | */ |
| 12 | 12 | public function normalizeCacheLifeTime($widget) |
| 13 | 13 | { |
| 14 | - if (! property_exists($widget, 'cacheLifeTime')) { |
|
| 15 | - $widget->cacheLifeTime = (int) (env('WIDGET_DEFAULT_CACHE_LIFETIME', 0)); |
|
| 14 | + if (!property_exists($widget, 'cacheLifeTime')) { |
|
| 15 | + $widget->cacheLifeTime = (int)(env('WIDGET_DEFAULT_CACHE_LIFETIME', 0)); |
|
| 16 | 16 | } |
| 17 | 17 | |
| 18 | 18 | if ($widget->cacheLifeTime === 'forever') { |
@@ -27,7 +27,7 @@ discard block |
||
| 27 | 27 | */ |
| 28 | 28 | public function normalizeCacheTags($widget) |
| 29 | 29 | { |
| 30 | - if (! $this->cacheCanUseTags() || ! property_exists($widget, 'cacheTags')) { |
|
| 30 | + if (!$this->cacheCanUseTags() || !property_exists($widget, 'cacheTags')) { |
|
| 31 | 31 | return $widget->cacheTags = null; |
| 32 | 32 | } |
| 33 | 33 | |
@@ -44,6 +44,6 @@ discard block |
||
| 44 | 44 | */ |
| 45 | 45 | private function cacheCanUseTags() |
| 46 | 46 | { |
| 47 | - return ! in_array(env('CACHE_DRIVER', 'file'), ['file', 'database']); |
|
| 47 | + return !in_array(env('CACHE_DRIVER', 'file'), ['file', 'database']); |
|
| 48 | 48 | } |
| 49 | 49 | } |
@@ -15,15 +15,15 @@ discard block |
||
| 15 | 15 | $presenter = $widget->presenter; |
| 16 | 16 | $this->checkPresenterExists($presenter); |
| 17 | 17 | } else { |
| 18 | - $presenter = get_class($widget).'Presenter'; |
|
| 19 | - if (! class_exists($presenter)) { |
|
| 18 | + $presenter = get_class($widget) . 'Presenter'; |
|
| 19 | + if (!class_exists($presenter)) { |
|
| 20 | 20 | return $widget->presenter = null; |
| 21 | 21 | } |
| 22 | 22 | } |
| 23 | 23 | |
| 24 | 24 | $this->checkPresentMethodExists($presenter); |
| 25 | 25 | |
| 26 | - $widget->presenter = $presenter.'@present'; |
|
| 26 | + $widget->presenter = $presenter . '@present'; |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |
@@ -31,8 +31,8 @@ discard block |
||
| 31 | 31 | */ |
| 32 | 32 | private function checkPresentMethodExists($presenter) |
| 33 | 33 | { |
| 34 | - if (! method_exists($presenter, 'present')) { |
|
| 35 | - throw new \InvalidArgumentException("'present' method not found on : ".$presenter); |
|
| 34 | + if (!method_exists($presenter, 'present')) { |
|
| 35 | + throw new \InvalidArgumentException("'present' method not found on : " . $presenter); |
|
| 36 | 36 | } |
| 37 | 37 | } |
| 38 | 38 | |
@@ -41,7 +41,7 @@ discard block |
||
| 41 | 41 | */ |
| 42 | 42 | private function checkPresenterExists($presenter) |
| 43 | 43 | { |
| 44 | - if (! class_exists($presenter)) { |
|
| 44 | + if (!class_exists($presenter)) { |
|
| 45 | 45 | throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found."); |
| 46 | 46 | } |
| 47 | 47 | } |
@@ -17,12 +17,12 @@ |
||
| 17 | 17 | // replace slashes with dots |
| 18 | 18 | $className = str_replace(['\\', '/'], '.', $className); |
| 19 | 19 | |
| 20 | - if (! property_exists($widget, 'template')) { |
|
| 21 | - $widget->template = 'Widgets::'.$className.'View'; |
|
| 20 | + if (!property_exists($widget, 'template')) { |
|
| 21 | + $widget->template = 'Widgets::' . $className . 'View'; |
|
| 22 | 22 | } |
| 23 | 23 | |
| 24 | - if (! view()->exists($widget->template)) { |
|
| 25 | - throw new \InvalidArgumentException("View file [{$className}View] not found by: '".class_basename($widget)." '"); |
|
| 24 | + if (!view()->exists($widget->template)) { |
|
| 25 | + throw new \InvalidArgumentException("View file [{$className}View] not found by: '" . class_basename($widget) . " '"); |
|
| 26 | 26 | } |
| 27 | 27 | } |
| 28 | 28 | } |
@@ -46,6 +46,6 @@ |
||
| 46 | 46 | */ |
| 47 | 47 | private function _makeCacheKey($arg, $widget) |
| 48 | 48 | { |
| 49 | - return md5(json_encode($arg, JSON_FORCE_OBJECT).$widget->template.class_basename($widget)); |
|
| 49 | + return md5(json_encode($arg, JSON_FORCE_OBJECT) . $widget->template . class_basename($widget)); |
|
| 50 | 50 | } |
| 51 | 51 | } |
@@ -60,7 +60,7 @@ |
||
| 60 | 60 | $contextAs = 'data'; |
| 61 | 61 | if (property_exists($widget, 'contextAs')) { |
| 62 | 62 | // removes the $ sign. |
| 63 | - $contextAs = str_replace('$', '', (string) $widget->contextAs); |
|
| 63 | + $contextAs = str_replace('$', '', (string)$widget->contextAs); |
|
| 64 | 64 | } |
| 65 | 65 | $widget->contextAs = $contextAs; |
| 66 | 66 | } |
@@ -23,7 +23,7 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | public function widgetShouldUseCache() |
| 25 | 25 | { |
| 26 | - return (env('WIDGET_CACHE', false) !== false) && (! app()->environment('testing')); |
|
| 26 | + return (env('WIDGET_CACHE', false) !== false) && (!app()->environment('testing')); |
|
| 27 | 27 | } |
| 28 | 28 | |
| 29 | 29 | /** |