Passed
Push — master ( 25c6d3...98c284 )
by Iman
03:00
created
src/helpers.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -1,20 +1,20 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Utils/Normalizers/ContextAsNormalizer.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/WidgetsServiceProvider.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,11 +17,11 @@  discard block
 block discarded – undo
17 17
     {
18 18
         $this->_registerDebugbar();
19 19
         $this->publishes([
20
-            __DIR__.'/config/config.php' => config_path('widgetize.php'),
20
+            __DIR__ . '/config/config.php' => config_path('widgetize.php'),
21 21
         ]);
22 22
 
23 23
         $this->defineDirectives();
24
-        $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets');
24
+        $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets');
25 25
     }
26 26
 
27 27
     /**
@@ -38,7 +38,7 @@  discard block
 block discarded – undo
38 38
     {
39 39
         $omitParenthesis = version_compare($this->app->version(), '5.3', '<');
40 40
 
41
-        Blade::directive('widget', function ($expression) use ($omitParenthesis) {
41
+        Blade::directive('widget', function($expression) use ($omitParenthesis) {
42 42
             $expression = $omitParenthesis ? $expression : "($expression)";
43 43
 
44 44
             return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>";
@@ -52,7 +52,7 @@  discard block
 block discarded – undo
52 52
      */
53 53
     public function register()
54 54
     {
55
-        $this->mergeConfigFrom(__DIR__.'/config/config.php', 'widgetize');
55
+        $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'widgetize');
56 56
         $this->commands('command.imanghafoori.widget');
57 57
         app(RouteMacros::class)->registerMacros();
58 58
         app(SingletonServices::class)->registerSingletons($this->app);
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
 
61 61
     private function _registerDebugbar()
62 62
     {
63
-        if (! $this->app->offsetExists('debugbar')) {
63
+        if (!$this->app->offsetExists('debugbar')) {
64 64
             return;
65 65
         }
66 66
 
67
-        $this->app->singleton('widgetize.debugger', function () {
67
+        $this->app->singleton('widgetize.debugger', function() {
68 68
             return new MessagesCollector('Widgets');
69 69
         });
70 70
 
Please login to merge, or discard this patch.
src/Utils/WidgetJsonifier.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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.
Please login to merge, or discard this patch.
src/Utils/Normalizers/CacheTagsNormalizer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -13,7 +13,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
         }
Please login to merge, or discard this patch.
src/SingletonServices.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -45,11 +45,11 @@
 block discarded – undo
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);
Please login to merge, or discard this patch.
src/Utils/Policies.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -11,7 +11,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
     /**
Please login to merge, or discard this patch.
src/Utils/Normalizers/CacheNormalizer.php 1 patch
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -14,12 +14,12 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 }
Please login to merge, or discard this patch.
src/Utils/WidgetRenderer.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -32,7 +32,7 @@  discard block
 block discarded – undo
32 32
         }
33 33
 
34 34
         if (is_array($widget)) {
35
-            $widget = (object) $widget;
35
+            $widget = (object)$widget;
36 36
         }
37 37
 
38 38
         event('widgetize.rendering_widget', [$widget]);
@@ -56,7 +56,7 @@  discard block
 block discarded – undo
56 56
             return resolve($widget);
57 57
         }
58 58
 
59
-        $widget = app()->getNamespace().'Widgets\\'.$widget;
59
+        $widget = app()->getNamespace() . 'Widgets\\' . $widget;
60 60
 
61 61
         return resolve($widget);
62 62
     }
@@ -72,13 +72,13 @@  discard block
 block discarded – undo
72 72
     private function generateHtml($widget, ...$args)
73 73
     {
74 74
         // Everything inside this function is executed only when the cache is not available.
75
-        $expensivePhpCode = function () use ($widget, $args) {
75
+        $expensivePhpCode = function() use ($widget, $args) {
76 76
             $this->makeDataForView($widget, $args);
77 77
 
78 78
             return $this->renderTemplate($widget, ...$args);
79 79
         };
80 80
 
81
-        if (! $widget->cacheView) {
81
+        if (!$widget->cacheView) {
82 82
             return $expensivePhpCode();
83 83
         }
84 84
 
@@ -94,7 +94,7 @@  discard block
 block discarded – undo
94 94
      */
95 95
     private function makeDataForView($widget, array $args)
96 96
     {
97
-        $expensiveCode = function () use ($widget, $args) {
97
+        $expensiveCode = function() use ($widget, $args) {
98 98
             $viewData = $this->callController($widget, $args);
99 99
 
100 100
             if ($widget->presenter) {
@@ -127,7 +127,7 @@  discard block
 block discarded – undo
127 127
         try {
128 128
             $this->html = view($widget->template, $data)->render();
129 129
         } catch (\Throwable $t) {
130
-            throw new \ErrorException('There was some error rendering '.get_class($widget).', template file: \''.$widget->template.'\' Error: '.$t->getMessage());
130
+            throw new \ErrorException('There was some error rendering ' . get_class($widget) . ', template file: \'' . $widget->template . '\' Error: ' . $t->getMessage());
131 131
         }
132 132
 
133 133
         // We try to minify the html before storing it in cache to save space.
@@ -146,7 +146,7 @@  discard block
 block discarded – undo
146 146
 
147 147
     private function callController($widget, array $args)
148 148
     {
149
-        if (! isset($widget->controller)) {
149
+        if (!isset($widget->controller)) {
150 150
             $viewData = [];
151 151
         } elseif (is_array($widget->controller) && is_string($widget->controller[0])) {
152 152
             $viewData = call_user_func_array($widget->controller, $args);
Please login to merge, or discard this patch.