Completed
Push — master ( 7a1f59...0e8a33 )
by Iman
11s
created
src/Utils/Normalizers/PresenterNormalizer.php 1 patch
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -15,15 +15,15 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 block discarded – undo
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
     }
Please login to merge, or discard this patch.
src/Utils/CacheTag.php 1 patch
Doc Comments   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -44,7 +44,7 @@  discard block
 block discarded – undo
44 44
     /**
45 45
      * Set token in Memory for fast access within the same request.
46 46
      * @param $tag string
47
-     * @param $token string
47
+     * @param string $token string
48 48
      * @return string
49 49
      */
50 50
     private function setTokenInMemory($tag, $token)
@@ -55,7 +55,7 @@  discard block
 block discarded – undo
55 55
     /**
56 56
      * Save token to disk for later requests.
57 57
      * @param $tag string
58
-     * @param $token string
58
+     * @param string $token string
59 59
      */
60 60
     private function persistToken($tag, $token)
61 61
     {
Please login to merge, or discard this patch.
src/WidgetGenerator.php 2 patches
Doc Comments   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -111,7 +111,7 @@
 block discarded – undo
111 111
 
112 112
     /**
113 113
      * Creates the widget class.
114
-     * @return bool
114
+     * @return false|null
115 115
      */
116 116
     private function _makeWidgetClass()
117 117
     {
Please login to merge, or discard this patch.
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -36,7 +36,7 @@  discard block
 block discarded – undo
36 36
     {
37 37
         $this->_makeWidgetClass();
38 38
 
39
-        if (! $this->option('plain')) {
39
+        if (!$this->option('plain')) {
40 40
             $this->createView();
41 41
         }
42 42
     }
@@ -51,14 +51,14 @@  discard block
 block discarded – undo
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
     /**
@@ -70,7 +70,7 @@  discard block
 block discarded – undo
70 70
     {
71 71
         $stubName = $this->option('plain') ? 'widget_plain' : 'widget';
72 72
 
73
-        return __DIR__."/../stubs/$stubName.stub";
73
+        return __DIR__ . "/../stubs/$stubName.stub";
74 74
     }
75 75
 
76 76
     /**
@@ -82,7 +82,7 @@  discard block
 block discarded – undo
82 82
      */
83 83
     protected function getDefaultNamespace($rootNamespace)
84 84
     {
85
-        return $rootNamespace.'\\Widgets';
85
+        return $rootNamespace . '\\Widgets';
86 86
     }
87 87
 
88 88
     /**
@@ -123,7 +123,7 @@  discard block
 block discarded – undo
123 123
         // to create the class and overwrite the user's code. So, we will bail out so the
124 124
         // code is untouched. Otherwise, we will continue generating this class' files.
125 125
         if ($this->alreadyExists($this->getNameInput())) {
126
-            $this->error($this->qualifyClass($this->getNameInput()).'.php - Already exists (@_@)');
126
+            $this->error($this->qualifyClass($this->getNameInput()) . '.php - Already exists (@_@)');
127 127
 
128 128
             return false;
129 129
         }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
 
136 136
         $this->files->put($path, $this->buildClass($name));
137 137
 
138
-        $this->info(' - '.$name.'.php - was created.  (^_^)');
138
+        $this->info(' - ' . $name . '.php - was created.  (^_^)');
139 139
     }
140 140
 
141 141
     /**
Please login to merge, or discard this patch.
src/WidgetsServiceProvider.php 1 patch
Spacing   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@  discard block
 block discarded – undo
21 21
     public function boot()
22 22
     {
23 23
         $this->publishes([
24
-            __DIR__.'/config/config.php' => config_path('widgetize.php'),
24
+            __DIR__ . '/config/config.php' => config_path('widgetize.php'),
25 25
         ]);
26 26
 
27 27
         $this->_defineDirectives();
28
-        $this->loadViewsFrom($this->app->basePath().'/app/Widgets/', 'Widgets');
28
+        $this->loadViewsFrom($this->app->basePath() . '/app/Widgets/', 'Widgets');
29 29
     }
30 30
 
31 31
     /**
@@ -35,7 +35,7 @@  discard block
 block discarded – undo
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}; ?>";
@@ -49,7 +49,7 @@  discard block
 block discarded – undo
49 49
      */
50 50
     public function register()
51 51
     {
52
-        $this->mergeConfigFrom(__DIR__.'/config/config.php', 'widgetize');
52
+        $this->mergeConfigFrom(__DIR__ . '/config/config.php', 'widgetize');
53 53
         $this->commands('command.imanghafoori.widget');
54 54
         $this->_registerSingletons();
55 55
         $this->_registerMacros();
@@ -60,11 +60,11 @@  discard block
 block discarded – undo
60 60
      */
61 61
     private function _registerSingletons()
62 62
     {
63
-        $this->app->singleton('command.imanghafoori.widget', function ($app) {
63
+        $this->app->singleton('command.imanghafoori.widget', function($app) {
64 64
             return $app['Imanghafoori\Widgets\WidgetGenerator'];
65 65
         });
66 66
 
67
-        $this->app->singleton(Normalizer::class, function () {
67
+        $this->app->singleton(Normalizer::class, function() {
68 68
             $cacheNormalizer = new CacheNormalizer();
69 69
             $tplNormalizer = new TemplateNormalizer();
70 70
             $presenterNormalizer = new PresenterNormalizer();
@@ -73,55 +73,55 @@  discard block
 block discarded – undo
73 73
             return new Utils\Normalizer($tplNormalizer, $cacheNormalizer, $presenterNormalizer, $ctrlNormalizer);
74 74
         });
75 75
 
76
-        $this->app->singleton(Utils\HtmlMinifier::class, function () {
76
+        $this->app->singleton(Utils\HtmlMinifier::class, function() {
77 77
             return new Utils\HtmlMinifier();
78 78
         });
79 79
 
80
-        $this->app->singleton(Utils\DebugInfo::class, function () {
80
+        $this->app->singleton(Utils\DebugInfo::class, function() {
81 81
             return new Utils\DebugInfo();
82 82
         });
83 83
 
84
-        $this->app->singleton(Utils\Policies::class, function () {
84
+        $this->app->singleton(Utils\Policies::class, function() {
85 85
             return new Utils\Policies();
86 86
         });
87 87
 
88
-        $this->app->singleton(Utils\Cache::class, function () {
88
+        $this->app->singleton(Utils\Cache::class, function() {
89 89
             return new Utils\Cache();
90 90
         });
91 91
 
92
-        $this->app->singleton(Utils\CacheTag::class, function () {
92
+        $this->app->singleton(Utils\CacheTag::class, function() {
93 93
             return new Utils\CacheTag();
94 94
         });
95 95
 
96
-        $this->app->singleton(Utils\WidgetRenderer::class, function () {
96
+        $this->app->singleton(Utils\WidgetRenderer::class, function() {
97 97
             return new Utils\WidgetRenderer();
98 98
         });
99 99
     }
100 100
 
101 101
     private function _registerMacros()
102 102
     {
103
-        Route::macro('view', function ($url, $view, $name = null) {
103
+        Route::macro('view', function($url, $view, $name = null) {
104 104
             return Route::get($url, [
105 105
                 'as' => $name,
106
-                'uses' => function () use ($view) {
106
+                'uses' => function() use ($view) {
107 107
                     return view($view);
108 108
                 },
109 109
             ]);
110 110
         });
111 111
 
112
-        Route::macro('widget', function ($url, $widget, $name = null) {
112
+        Route::macro('widget', function($url, $widget, $name = null) {
113 113
             return Route::get($url, [
114 114
                 'as' => $name,
115
-                'uses' => function (...$args) use ($widget) {
115
+                'uses' => function(...$args) use ($widget) {
116 116
                     return render_widget($widget, $args);
117 117
                 },
118 118
             ]);
119 119
         });
120 120
 
121
-        Route::macro('jsonWidget', function ($url, $widget, $name = null) {
121
+        Route::macro('jsonWidget', function($url, $widget, $name = null) {
122 122
             return Route::get($url, [
123 123
                 'as' => $name,
124
-                'uses' => function (...$args) use ($widget) {
124
+                'uses' => function(...$args) use ($widget) {
125 125
                     return json_widget($widget, $args);
126 126
                 },
127 127
             ]);
Please login to merge, or discard this patch.
src/Utils/Cache.php 1 patch
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -30,7 +30,7 @@  discard block
 block discarded – undo
30 30
 
31 31
         $cache = app('cache');
32 32
 
33
-        if (! empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) {
33
+        if (!empty($widgetObj->cacheTags) && $this->cacheDriverSupportsTags()) {
34 34
             $cache = $cache->tags($widgetObj->cacheTags);
35 35
         }
36 36
 
@@ -61,11 +61,11 @@  discard block
 block discarded – undo
61 61
             $_key = json_encode($widget->extraCacheKeyDependency($arg));
62 62
         }
63 63
 
64
-        if (! $this->cacheDriverSupportsTags()) {
64
+        if (!$this->cacheDriverSupportsTags()) {
65 65
             $_key .= json_encode($this->getTagTokens($widget->cacheTags));
66 66
         }
67 67
 
68
-        $_key .= json_encode($arg, JSON_FORCE_OBJECT).app()->getLocale().$form.$widget->template.get_class($widget);
68
+        $_key .= json_encode($arg, JSON_FORCE_OBJECT) . app()->getLocale() . $form . $widget->template . get_class($widget);
69 69
 
70 70
         return md5($_key);
71 71
     }
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
      */
77 77
     private function cacheDriverSupportsTags()
78 78
     {
79
-        return ! in_array(config('cache.default', 'file'), ['file', 'database']);
79
+        return !in_array(config('cache.default', 'file'), ['file', 'database']);
80 80
     }
81 81
 
82 82
     /**
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
      */
86 86
     private function getTagTokens(array $cacheTags)
87 87
     {
88
-        return array_map(function ($tag) {
88
+        return array_map(function($tag) {
89 89
             return $this->_cacheTag->getTagToken($tag);
90 90
         }, $cacheTags);
91 91
     }
Please login to merge, or discard this patch.
src/Utils/WidgetRenderer.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -51,7 +51,7 @@  discard block
 block discarded – undo
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);
@@ -118,7 +118,7 @@  discard block
 block discarded – undo
118 118
             return app($widget);
119 119
         }
120 120
 
121
-        $widget = app()->getNamespace().'Widgets\\'.$widget;
121
+        $widget = app()->getNamespace() . 'Widgets\\' . $widget;
122 122
 
123 123
         return app($widget);
124 124
     }
Please login to merge, or discard this patch.
src/Utils/Normalizers/ControllerNormalizer.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -24,7 +24,7 @@  discard block
 block discarded – undo
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
 block discarded – undo
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
 
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
         // then we decide to call data method on that instead.
54 54
         if (property_exists($widget, 'controller')) {
55 55
             $ctrlClass = $widget->controller;
56
-            $controllerMethod = ($ctrlClass).'@data';
56
+            $controllerMethod = ($ctrlClass) . '@data';
57 57
         }
58 58
 
59 59
         return [$controllerMethod, $ctrlClass];
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
@@ -39,7 +39,7 @@  discard block
 block discarded – undo
39 39
     private function _generateJson($widget, ...$args)
40 40
     {
41 41
         // Everything inside this function is executed only when the cache is not available.
42
-        $expensivePhpCode = function () use ($widget, $args) {
42
+        $expensivePhpCode = function() use ($widget, $args) {
43 43
             $data = \App::call($widget->controller, ...$args);
44 44
             // render the template with the resulting data.
45 45
             return response()->json($data, 200);
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
      */
60 60
     private function _makeWidgetObj($widget)
61 61
     {
62
-        $widget = app()->getNamespace().'Widgets\\'.$widget;
62
+        $widget = app()->getNamespace() . 'Widgets\\' . $widget;
63 63
 
64 64
         return app($widget);
65 65
     }
Please login to merge, or discard this patch.
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.