@@ -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); |
@@ -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 | } |
@@ -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 | } |
@@ -98,7 +98,7 @@ discard block |
||
98 | 98 | } |
99 | 99 | |
100 | 100 | /** |
101 | - * @return mixed|string |
|
101 | + * @return string |
|
102 | 102 | */ |
103 | 103 | private function _getViewPath() |
104 | 104 | { |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | |
111 | 111 | /** |
112 | 112 | * Creates the widget class |
113 | - * @return bool |
|
113 | + * @return false|null |
|
114 | 114 | */ |
115 | 115 | private function _makeWidgetClass() |
116 | 116 | { |
@@ -51,14 +51,14 @@ discard block |
||
51 | 51 | $path = $this->_getViewPath(); |
52 | 52 | |
53 | 53 | if ($this->files->exists($path)) { |
54 | - $this->error($this->qualifyClass($this->getNameInput())."View.blade.php - Already exists! (@_@)"); |
|
54 | + $this->error($this->qualifyClass($this->getNameInput()) . "View.blade.php - Already exists! (@_@)"); |
|
55 | 55 | |
56 | 56 | return; |
57 | 57 | } |
58 | 58 | |
59 | 59 | $this->files->put($path, $this->_getViewStub()); |
60 | 60 | |
61 | - $this->info(' - '.$this->qualifyClass($this->getNameInput())."View.blade.php - was created. (^_^)"); |
|
61 | + $this->info(' - ' . $this->qualifyClass($this->getNameInput()) . "View.blade.php - was created. (^_^)"); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | // to create the class and overwrite the user's code. So, we will bail out so the |
123 | 123 | // code is untouched. Otherwise, we will continue generating this class' files. |
124 | 124 | if ($this->alreadyExists($this->getNameInput())) { |
125 | - $this->error($this->qualifyClass($this->getNameInput()).".php - Already exists (@_@)"); |
|
125 | + $this->error($this->qualifyClass($this->getNameInput()) . ".php - Already exists (@_@)"); |
|
126 | 126 | |
127 | 127 | return false; |
128 | 128 | } |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | |
135 | 135 | $this->files->put($path, $this->buildClass($name)); |
136 | 136 | |
137 | - $this->info(' - '.$name.'.php - was created. (^_^)'); |
|
137 | + $this->info(' - ' . $name . '.php - was created. (^_^)'); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -24,7 +24,7 @@ discard block |
||
24 | 24 | */ |
25 | 25 | private function checkControllerExists($ctrlClass) |
26 | 26 | { |
27 | - if (! class_exists($ctrlClass)) { |
|
27 | + if (!class_exists($ctrlClass)) { |
|
28 | 28 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
29 | 29 | } |
30 | 30 | } |
@@ -34,8 +34,8 @@ discard block |
||
34 | 34 | */ |
35 | 35 | private function checkDataMethodExists($ctrlClass) |
36 | 36 | { |
37 | - if (! method_exists($ctrlClass, 'data')) { |
|
38 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
37 | + if (!method_exists($ctrlClass, 'data')) { |
|
38 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 |
@@ -106,7 +106,7 @@ |
||
106 | 106 | } |
107 | 107 | |
108 | 108 | /** |
109 | - * @param $widget |
|
109 | + * @param string $widget |
|
110 | 110 | * @return \Illuminate\Foundation\Application|mixed |
111 | 111 | */ |
112 | 112 | private function _makeWidgetObj($widget) |
@@ -51,7 +51,7 @@ discard block |
||
51 | 51 | private function _generateHtml($widget, ...$args) |
52 | 52 | { |
53 | 53 | // Everything inside this function is executed only when the cache is not available. |
54 | - $expensivePhpCode = function () use ($widget, $args) { |
|
54 | + $expensivePhpCode = function() use ($widget, $args) { |
|
55 | 55 | $this->_makeDataForView($widget, $args); |
56 | 56 | // render the template with the resulting data. |
57 | 57 | return $this->renderTemplate($widget); |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | private function _makeWidgetObj($widget) |
112 | 112 | { |
113 | - $widget = app()->getNamespace().'Widgets\\'.$widget; |
|
113 | + $widget = app()->getNamespace() . 'Widgets\\' . $widget; |
|
114 | 114 | return $widgetObj = app($widget); |
115 | 115 | } |
116 | 116 | } |
@@ -35,7 +35,7 @@ discard block |
||
35 | 35 | { |
36 | 36 | $omitParenthesis = version_compare($this->app->version(), '5.3', '<'); |
37 | 37 | |
38 | - Blade::directive('widget', function ($expression) use ($omitParenthesis) { |
|
38 | + Blade::directive('widget', function($expression) use ($omitParenthesis) { |
|
39 | 39 | $expression = $omitParenthesis ? $expression : "($expression)"; |
40 | 40 | |
41 | 41 | return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>"; |
@@ -59,11 +59,11 @@ discard block |
||
59 | 59 | */ |
60 | 60 | private function _registerSingletons() |
61 | 61 | { |
62 | - $this->app->singleton('command.imanghafoori.widget', function ($app) { |
|
62 | + $this->app->singleton('command.imanghafoori.widget', function($app) { |
|
63 | 63 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
64 | 64 | }); |
65 | 65 | |
66 | - $this->app->singleton(Normalizer::class, function () { |
|
66 | + $this->app->singleton(Normalizer::class, function() { |
|
67 | 67 | $cacheNormalizer = new CacheNormalizer(); |
68 | 68 | $tplNormalizer = new TemplateNormalizer(); |
69 | 69 | $presenterNormalizer = new PresenterNormalizer(); |
@@ -72,23 +72,23 @@ discard block |
||
72 | 72 | return new Utils\Normalizer($tplNormalizer, $cacheNormalizer, $presenterNormalizer, $ctrlNormalizer); |
73 | 73 | }); |
74 | 74 | |
75 | - $this->app->singleton(Utils\HtmlMinifier::class, function () { |
|
75 | + $this->app->singleton(Utils\HtmlMinifier::class, function() { |
|
76 | 76 | return new Utils\HtmlMinifier(); |
77 | 77 | }); |
78 | 78 | |
79 | - $this->app->singleton(Utils\DebugInfo::class, function () { |
|
79 | + $this->app->singleton(Utils\DebugInfo::class, function() { |
|
80 | 80 | return new Utils\DebugInfo(); |
81 | 81 | }); |
82 | 82 | |
83 | - $this->app->singleton(Utils\Policies::class, function () { |
|
83 | + $this->app->singleton(Utils\Policies::class, function() { |
|
84 | 84 | return new Utils\Policies(); |
85 | 85 | }); |
86 | 86 | |
87 | - $this->app->singleton(Utils\Cache::class, function () { |
|
87 | + $this->app->singleton(Utils\Cache::class, function() { |
|
88 | 88 | return new Utils\Cache(); |
89 | 89 | }); |
90 | 90 | |
91 | - $this->app->singleton(Utils\WidgetRenderer::class, function () { |
|
91 | + $this->app->singleton(Utils\WidgetRenderer::class, function() { |
|
92 | 92 | return new Utils\WidgetRenderer(); |
93 | 93 | }); |
94 | 94 | } |
@@ -23,7 +23,7 @@ |
||
23 | 23 | */ |
24 | 24 | public function widgetShouldUseCache() |
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 | /** |
@@ -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) (config('widgetize.default_cache_lifetime', 0)); |
|
14 | + if (!property_exists($widget, 'cacheLifeTime')) { |
|
15 | + $widget->cacheLifeTime = (int)(config('widgetize.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 | } |