@@ -1,20 +1,20 @@ |
||
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); |
7 | 7 | } |
8 | 8 | } |
9 | 9 | |
10 | -if (! function_exists('expire_widgets')) { |
|
10 | +if (!function_exists('expire_widgets')) { |
|
11 | 11 | function expire_widgets($tags) |
12 | 12 | { |
13 | 13 | return app(\Imanghafoori\Widgets\Utils\Cache::class)->expireTaggedWidgets($tags); |
14 | 14 | } |
15 | 15 | } |
16 | 16 | |
17 | -if (! function_exists('json_widget')) { |
|
17 | +if (!function_exists('json_widget')) { |
|
18 | 18 | function json_widget($widget, ...$args) |
19 | 19 | { |
20 | 20 | return app(\Imanghafoori\Widgets\Utils\WidgetJsonifier::class)->jsonResponse($widget, ...$args); |
@@ -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 | } |
@@ -34,7 +34,7 @@ discard block |
||
34 | 34 | */ |
35 | 35 | private function makeWidgetObj(string $widget) |
36 | 36 | { |
37 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
37 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
38 | 38 | |
39 | 39 | return app($widget); |
40 | 40 | } |
@@ -50,7 +50,7 @@ discard block |
||
50 | 50 | private function generateJson($widget, ...$args) |
51 | 51 | { |
52 | 52 | // Everything inside this function is executed only when the cache is not available. |
53 | - $expensivePhpCode = function () use ($widget, $args) { |
|
53 | + $expensivePhpCode = function() use ($widget, $args) { |
|
54 | 54 | $data = \App::call($widget->controller, ...$args); |
55 | 55 | |
56 | 56 | // render the template with the resulting data. |
@@ -13,7 +13,7 @@ discard block |
||
13 | 13 | */ |
14 | 14 | public function normalize($widget): void |
15 | 15 | { |
16 | - if (! property_exists($widget, 'cacheTags')) { |
|
16 | + if (!property_exists($widget, 'cacheTags')) { |
|
17 | 17 | $widget->cacheTags = []; |
18 | 18 | } elseif (is_array($widget->cacheTags)) { |
19 | 19 | $this->checkTagForString($widget); |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | */ |
29 | 29 | private function errorOut($widget, $tag = null): void |
30 | 30 | { |
31 | - $tag = $tag ? ' '.$tag.'is not string' : ''; |
|
32 | - throw new \InvalidArgumentException('Cache Tags on "'.get_class($widget).'" must be of type Array with String elements.'.$tag); |
|
31 | + $tag = $tag ? ' ' . $tag . 'is not string' : ''; |
|
32 | + throw new \InvalidArgumentException('Cache Tags on "' . get_class($widget) . '" must be of type Array with String elements.' . $tag); |
|
33 | 33 | } |
34 | 34 | |
35 | 35 | /** |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | protected function checkTagForString($widget): void |
39 | 39 | { |
40 | 40 | foreach ($widget->cacheTags as $tag) { |
41 | - if (! is_string($tag)) { |
|
41 | + if (!is_string($tag)) { |
|
42 | 42 | $this->errorOut($widget); |
43 | 43 | } |
44 | 44 | } |
@@ -45,11 +45,11 @@ |
||
45 | 45 | |
46 | 46 | public function registerSingletons(Container $app) |
47 | 47 | { |
48 | - $app->singleton('command.imanghafoori.widget', function (Container $app) { |
|
48 | + $app->singleton('command.imanghafoori.widget', function(Container $app) { |
|
49 | 49 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
50 | 50 | }); |
51 | 51 | |
52 | - $app->singleton(Normalizer::class, function () { |
|
52 | + $app->singleton(Normalizer::class, function() { |
|
53 | 53 | $mainNormalizer = new Utils\Normalizer(); |
54 | 54 | foreach ($this->normalizers as $normalizer) { |
55 | 55 | $mainNormalizer->addNormalizer(new $normalizer); |
@@ -11,7 +11,7 @@ discard block |
||
11 | 11 | */ |
12 | 12 | public function widgetShouldHaveDebugInfo(): bool |
13 | 13 | { |
14 | - return config('widgetize.debug_info') && ! app()->environment('production'); |
|
14 | + return config('widgetize.debug_info') && !app()->environment('production'); |
|
15 | 15 | } |
16 | 16 | |
17 | 17 | /** |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | */ |
24 | 24 | public function widgetShouldUseCache(): bool |
25 | 25 | { |
26 | - return config('widgetize.enable_cache') && (! app()->environment('testing')); |
|
26 | + return config('widgetize.enable_cache') && (!app()->environment('testing')); |
|
27 | 27 | } |
28 | 28 | |
29 | 29 | /** |
@@ -14,12 +14,12 @@ discard block |
||
14 | 14 | */ |
15 | 15 | public function normalize($widget): void |
16 | 16 | { |
17 | - if (! property_exists($widget, 'cacheLifeTime')) { |
|
17 | + if (!property_exists($widget, 'cacheLifeTime')) { |
|
18 | 18 | $M = config('widgetize.default_cache_lifetime', 0); |
19 | 19 | $widget->cacheLifeTime = $this->makeFromSeconds($M * 60); |
20 | 20 | } |
21 | 21 | |
22 | - if (! property_exists($widget, 'cacheView')) { |
|
22 | + if (!property_exists($widget, 'cacheView')) { |
|
23 | 23 | $widget->cacheView = true; |
24 | 24 | } |
25 | 25 | |
@@ -41,6 +41,6 @@ discard block |
||
41 | 41 | |
42 | 42 | public function makeFromSeconds($s) |
43 | 43 | { |
44 | - return new \DateInterval('PT'.(string) ceil($s).'S'); |
|
44 | + return new \DateInterval('PT' . (string)ceil($s) . 'S'); |
|
45 | 45 | } |
46 | 46 | } |
@@ -39,7 +39,7 @@ discard block |
||
39 | 39 | { |
40 | 40 | $tpl = $this->getTplPath($this->widget->template); |
41 | 41 | |
42 | - $this->html = "<span title='WidgetObj : ".get_class($this->widget).".php
Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>"; |
|
42 | + $this->html = "<span title='WidgetObj : " . get_class($this->widget) . ".php
Template : {$tpl}{$this->cacheState()}'>{$this->html}</span>"; |
|
43 | 43 | } |
44 | 44 | |
45 | 45 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | */ |
50 | 50 | private function cacheState() |
51 | 51 | { |
52 | - if (! $this->policies->widgetShouldUseCache()) { |
|
52 | + if (!$this->policies->widgetShouldUseCache()) { |
|
53 | 53 | return ' 
 Cache: is globally turned off (You should put "enable_cache" => true in config\widgetize.php) '; |
54 | 54 | } |
55 | 55 | $l = $this->widget->cacheLifeTime->i ?? 0; |
@@ -59,7 +59,7 @@ discard block |
||
59 | 59 | |
60 | 60 | private function addHtmlComments(): void |
61 | 61 | { |
62 | - $this->html = "<!-- '{".get_class($this->widget)."' Widget Start -->".$this->html."<!-- '".get_class($this->widget)."' Widget End -->"; |
|
62 | + $this->html = "<!-- '{" . get_class($this->widget) . "' Widget Start -->" . $this->html . "<!-- '" . get_class($this->widget) . "' Widget End -->"; |
|
63 | 63 | } |
64 | 64 | |
65 | 65 | /** |
@@ -69,9 +69,9 @@ discard block |
||
69 | 69 | private function getTplPath(string $tpl) |
70 | 70 | { |
71 | 71 | if (Str::contains($tpl, 'Widgets::')) { |
72 | - $tpl = str_replace('Widgets::', app()->getNamespace().'Widgets\\', $tpl); |
|
72 | + $tpl = str_replace('Widgets::', app()->getNamespace() . 'Widgets\\', $tpl); |
|
73 | 73 | } |
74 | 74 | |
75 | - return str_replace('.', '\\', $tpl).'.blade.php'; |
|
75 | + return str_replace('.', '\\', $tpl) . '.blade.php'; |
|
76 | 76 | } |
77 | 77 | } |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | */ |
30 | 30 | private function checkControllerExists(string $ctrlClass): void |
31 | 31 | { |
32 | - if (! class_exists($ctrlClass)) { |
|
32 | + if (!class_exists($ctrlClass)) { |
|
33 | 33 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
34 | 34 | } |
35 | 35 | } |
@@ -44,8 +44,8 @@ discard block |
||
44 | 44 | } |
45 | 45 | |
46 | 46 | [$ctrlClass, $method] = $ctrlClass; |
47 | - if (! method_exists($ctrlClass, $method)) { |
|
48 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
47 | + if (!method_exists($ctrlClass, $method)) { |
|
48 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
49 | 49 | } |
50 | 50 | } |
51 | 51 | |
@@ -58,13 +58,13 @@ discard block |
||
58 | 58 | // We decide to call data method on the widget object by default. |
59 | 59 | // If the user has explicitly declared controller class path on |
60 | 60 | // widget then we decide to call data method on that instead. |
61 | - if (! property_exists($widget, 'controller')) { |
|
61 | + if (!property_exists($widget, 'controller')) { |
|
62 | 62 | return method_exists($widget, 'data') ? [[$widget, 'data'], null] : [null, null]; |
63 | 63 | } |
64 | 64 | |
65 | 65 | if (is_string($widget->controller)) { |
66 | - if (! Str::contains($widget->controller, '@')) { |
|
67 | - return [$widget->controller.'@data', $widget->controller]; |
|
66 | + if (!Str::contains($widget->controller, '@')) { |
|
67 | + return [$widget->controller . '@data', $widget->controller]; |
|
68 | 68 | } |
69 | 69 | $widget->controller = explode('@', $widget->controller); |
70 | 70 | } elseif (is_callable($widget->controller)) { |