Passed
Pull Request — master (#68)
by yasin
02:43
created
src/RouteMacros.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -15,10 +15,10 @@  discard block
 block discarded – undo
15 15
 
16 16
     private function registerWidget(): void
17 17
     {
18
-        Route::macro('widget', function ($url, $widget, $name = null) {
18
+        Route::macro('widget', function($url, $widget, $name = null) {
19 19
             return Route::get($url, [
20 20
                 'as' => $name,
21
-                'uses' => function (...$args) use ($widget) {
21
+                'uses' => function(...$args) use ($widget) {
22 22
                     return render_widget($widget, $args);
23 23
                 },
24 24
             ]);
@@ -27,10 +27,10 @@  discard block
 block discarded – undo
27 27
 
28 28
     private function registerJsonWidget(): void
29 29
     {
30
-        Route::macro('jsonWidget', function ($url, $widget, $name = null) {
30
+        Route::macro('jsonWidget', function($url, $widget, $name = null) {
31 31
             return Route::get($url, [
32 32
                 'as' => $name,
33
-                'uses' => function (...$args) use ($widget) {
33
+                'uses' => function(...$args) use ($widget) {
34 34
                     return json_widget($widget, $args);
35 35
                 },
36 36
             ]);
Please login to merge, or discard this patch.
src/Utils/Cache.php 1 patch
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -29,13 +29,13 @@  discard block
 block discarded – undo
29 29
      */
30 30
     public function cacheResult(array $args, callable $phpCode, $widgetObj, $form = 'HTML')
31 31
     {
32
-        if (! resolve(Policies::class)->widgetShouldUseCache() || $widgetObj->cacheLifeTime->s === 0) {
32
+        if (!resolve(Policies::class)->widgetShouldUseCache() || $widgetObj->cacheLifeTime->s === 0) {
33 33
             return $phpCode();
34 34
         }
35 35
 
36 36
         $cache = resolve('cache');
37 37
 
38
-        if (! empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) {
38
+        if (!empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) {
39 39
             $cache = $cache->tags($widgetObj->cacheTags);
40 40
         }
41 41
 
@@ -64,11 +64,11 @@  discard block
 block discarded – undo
64 64
             $_key = json_encode($widget->extraCacheKeyDependency($arg));
65 65
         }
66 66
 
67
-        if (! $this->cacheDriverSupportsTags()) {
67
+        if (!$this->cacheDriverSupportsTags()) {
68 68
             $_key .= json_encode($this->getTagTokens($widget->cacheTags));
69 69
         }
70 70
 
71
-        $_key .= json_encode($arg, JSON_FORCE_OBJECT).app()->getLocale().$form.$widget->template.get_class($widget);
71
+        $_key .= json_encode($arg, JSON_FORCE_OBJECT) . app()->getLocale() . $form . $widget->template . get_class($widget);
72 72
 
73 73
         return md5($_key);
74 74
     }
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
      */
80 80
     private function cacheDriverSupportsTags(): bool
81 81
     {
82
-        return ! in_array(config('cache.default', 'file'), ['file', 'database']);
82
+        return !in_array(config('cache.default', 'file'), ['file', 'database']);
83 83
     }
84 84
 
85 85
     /**
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
      */
89 89
     private function getTagTokens(array $cacheTags)
90 90
     {
91
-        return array_map(function ($tag) {
91
+        return array_map(function($tag) {
92 92
             return $this->_cacheTag->getTagToken($tag);
93 93
         }, $cacheTags);
94 94
     }
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
             return \Cache::tags($tags)->flush();
104 104
         }
105 105
 
106
-        foreach ((array) $tags as $tag) {
106
+        foreach ((array)$tags as $tag) {
107 107
             $this->_cacheTag->generateNewToken($tag);
108 108
         }
109 109
     }
Please login to merge, or discard this patch.
src/Utils/Normalizers/PresenterNormalizer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -17,7 +17,7 @@  discard block
 block discarded – undo
17 17
 
18 18
         if ($widget->presenter) {
19 19
             $this->checkPresentMethodExists($presenter);
20
-            $widget->presenter = $presenter.'@present';
20
+            $widget->presenter = $presenter . '@present';
21 21
         }
22 22
     }
23 23
 
@@ -26,8 +26,8 @@  discard block
 block discarded – undo
26 26
      */
27 27
     private function checkPresentMethodExists($presenter): void
28 28
     {
29
-        if (! method_exists($presenter, 'present')) {
30
-            throw new \InvalidArgumentException("'present' method not found on : ".$presenter);
29
+        if (!method_exists($presenter, 'present')) {
30
+            throw new \InvalidArgumentException("'present' method not found on : " . $presenter);
31 31
         }
32 32
     }
33 33
 
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
      */
37 37
     private function checkPresenterExists($presenter): void
38 38
     {
39
-        if (! class_exists($presenter)) {
39
+        if (!class_exists($presenter)) {
40 40
             throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found.");
41 41
         }
42 42
     }
@@ -51,8 +51,8 @@  discard block
 block discarded – undo
51 51
             $presenter = $widget->presenter;
52 52
             $this->checkPresenterExists($presenter);
53 53
         } else {
54
-            $presenter = get_class($widget).'Presenter';
55
-            if (! class_exists($presenter)) {
54
+            $presenter = get_class($widget) . 'Presenter';
55
+            if (!class_exists($presenter)) {
56 56
                 $widget->presenter = null;
57 57
             }
58 58
         }
Please login to merge, or discard this patch.
src/Utils/Normalizers/TemplateNormalizer.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -15,17 +15,17 @@
 block discarded – undo
15 15
     public function normalize($widget): void
16 16
     {
17 17
         // class name without namespace.
18
-        $className = str_replace(app()->getNamespace().'Widgets\\', '', get_class($widget));
18
+        $className = str_replace(app()->getNamespace() . 'Widgets\\', '', get_class($widget));
19 19
 
20 20
         // replace slashes with dots
21 21
         $className = str_replace(['\\', '/'], '.', $className);
22 22
 
23
-        if (! property_exists($widget, 'template')) {
24
-            $widget->template = 'Widgets::'.$className.'View';
23
+        if (!property_exists($widget, 'template')) {
24
+            $widget->template = 'Widgets::' . $className . 'View';
25 25
         }
26 26
 
27
-        if (! view()->exists($widget->template)) {
28
-            throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '".get_class($widget)." '");
27
+        if (!view()->exists($widget->template)) {
28
+            throw new \InvalidArgumentException("View file \"{$widget->template}\" not found by: '" . get_class($widget) . " '");
29 29
         }
30 30
     }
31 31
 }
Please login to merge, or discard this patch.
src/WidgetsServiceProvider.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -40,7 +40,7 @@  discard block
 block discarded – undo
40 40
     {
41 41
         $omitParenthesis = version_compare($this->app->version(), '5.3', '<');
42 42
 
43
-        Blade::directive('widget', function ($expression) use ($omitParenthesis) {
43
+        Blade::directive('widget', function($expression) use ($omitParenthesis) {
44 44
             $expression = $omitParenthesis ? $expression : "($expression)";
45 45
             if (strpos($expression, 'slotable') == false) {
46 46
                 return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>";
@@ -50,7 +50,7 @@  discard block
 block discarded – undo
50 50
 
51 51
         $this->defineSlotDirectives($omitParenthesis);
52 52
 
53
-        Blade::directive('endwidget', function () {
53
+        Blade::directive('endwidget', function() {
54 54
             $expression = $this->expression;
55 55
             return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->renderWidget{$expression}; ?>";
56 56
         });
@@ -68,12 +68,12 @@  discard block
 block discarded – undo
68 68
      */
69 69
     private function defineSlotDirectives($omitParenthesis)
70 70
     {
71
-        Blade::directive('slot', function ($slotName) use ($omitParenthesis) {
71
+        Blade::directive('slot', function($slotName) use ($omitParenthesis) {
72 72
             $slotName = $omitParenthesis ? $slotName : "($slotName)";
73 73
             return "<?php echo app(\\Imanghafoori\\Widgets\\Utils\\WidgetRenderer::class)->startSlot{$slotName};?>";
74 74
         });
75 75
 
76
-        Blade::directive('endslot', function () {
76
+        Blade::directive('endslot', function() {
77 77
             $contentKey = '$content';
78 78
             return "<?php 
79 79
                         $contentKey = ob_get_clean();
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
             return;
102 102
         }
103 103
 
104
-        $this->app->singleton('widgetize.debugger', function () {
104
+        $this->app->singleton('widgetize.debugger', function() {
105 105
             return new MessagesCollector('Widgets');
106 106
         });
107 107
 
Please login to merge, or discard this patch.
src/Utils/SlotRenderer.php 1 patch
Braces   +3 added lines, -2 removed lines patch added patch discarded remove patch
@@ -30,7 +30,8 @@
 block discarded – undo
30 30
      */
31 31
     private function assignSlots()
32 32
     {
33
-        if ($this->hasSlot())
34
-            $this->_viewData = array_merge($this->_viewData, $this->slots);
33
+        if ($this->hasSlot()) {
34
+                    $this->_viewData = array_merge($this->_viewData, $this->slots);
35
+        }
35 36
     }
36 37
 }
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
@@ -34,7 +34,7 @@  discard block
 block discarded – undo
34 34
         }
35 35
 
36 36
         if (is_array($widget)) {
37
-            $widget = (object) $widget;
37
+            $widget = (object)$widget;
38 38
         }
39 39
 
40 40
         event('widgetize.rendering_widget', [$widget]);
@@ -58,7 +58,7 @@  discard block
 block discarded – undo
58 58
             return resolve($widget);
59 59
         }
60 60
 
61
-        $widget = app()->getNamespace().'Widgets\\'.$widget;
61
+        $widget = app()->getNamespace() . 'Widgets\\' . $widget;
62 62
 
63 63
         return resolve($widget);
64 64
     }
@@ -74,7 +74,7 @@  discard block
 block discarded – undo
74 74
     private function generateHtml($widget, ...$args)
75 75
     {
76 76
         // Everything inside this function is executed only when the cache is not available.
77
-        $expensivePhpCode = function () use ($widget, $args) {
77
+        $expensivePhpCode = function() use ($widget, $args) {
78 78
             $this->makeDataForView($widget, $args);
79 79
 
80 80
             $this->assignSlots();
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
             return $this->renderTemplate($widget, ...$args);
83 83
         };
84 84
 
85
-        if (! $widget->cacheView) {
85
+        if (!$widget->cacheView) {
86 86
             return $expensivePhpCode();
87 87
         }
88 88
 
@@ -98,7 +98,7 @@  discard block
 block discarded – undo
98 98
      */
99 99
     private function makeDataForView($widget, array $args)
100 100
     {
101
-        $expensiveCode = function () use ($widget, $args) {
101
+        $expensiveCode = function() use ($widget, $args) {
102 102
             $viewData = $this->callController($widget, $args);
103 103
 
104 104
             if ($widget->presenter) {
@@ -131,7 +131,7 @@  discard block
 block discarded – undo
131 131
         try {
132 132
             $this->html = view($widget->template, $data)->render();
133 133
         } catch (\Throwable $t) {
134
-            throw new \ErrorException('There was some error rendering '.get_class($widget).', template file: \''.$widget->template.'\' Error: '.$t->getMessage());
134
+            throw new \ErrorException('There was some error rendering ' . get_class($widget) . ', template file: \'' . $widget->template . '\' Error: ' . $t->getMessage());
135 135
         }
136 136
 
137 137
         // We try to minify the html before storing it in cache to save space.
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 
151 151
     private function callController($widget, array $args)
152 152
     {
153
-        if (! isset($widget->controller)) {
153
+        if (!isset($widget->controller)) {
154 154
             $viewData = [];
155 155
         } elseif (is_array($widget->controller) && is_string($widget->controller[0])) {
156 156
             $viewData = call_user_func_array($widget->controller, $args);
Please login to merge, or discard this patch.