@@ -30,7 +30,7 @@ discard block |
||
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 |
||
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 |
||
76 | 76 | */ |
77 | 77 | private function cacheDriverSupportsTags() : bool |
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 |
||
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 | } |
@@ -100,7 +100,7 @@ discard block |
||
100 | 100 | return \Cache::tags($tags)->flush(); |
101 | 101 | } |
102 | 102 | |
103 | - foreach ((array) $tags as $tag) { |
|
103 | + foreach ((array)$tags as $tag) { |
|
104 | 104 | $this->_cacheTag->generateNewToken($tag); |
105 | 105 | } |
106 | 106 | } |
@@ -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 | } |
@@ -26,7 +26,7 @@ discard block |
||
26 | 26 | */ |
27 | 27 | private function checkControllerExists(string $ctrlClass): void |
28 | 28 | { |
29 | - if (! class_exists($ctrlClass)) { |
|
29 | + if (!class_exists($ctrlClass)) { |
|
30 | 30 | throw new \InvalidArgumentException("Controller class: [{$ctrlClass}] not found."); |
31 | 31 | } |
32 | 32 | } |
@@ -36,8 +36,8 @@ discard block |
||
36 | 36 | */ |
37 | 37 | private function checkDataMethodExists(string $ctrlClass): void |
38 | 38 | { |
39 | - if (! method_exists($ctrlClass, 'data')) { |
|
40 | - throw new \InvalidArgumentException("'data' method not found on ".$ctrlClass); |
|
39 | + if (!method_exists($ctrlClass, 'data')) { |
|
40 | + throw new \InvalidArgumentException("'data' method not found on " . $ctrlClass); |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | |
@@ -55,7 +55,7 @@ discard block |
||
55 | 55 | // then we decide to call data method on that instead. |
56 | 56 | if (property_exists($widget, 'controller')) { |
57 | 57 | $ctrlClass = $widget->controller; |
58 | - $controllerMethod = ($ctrlClass).'@data'; |
|
58 | + $controllerMethod = ($ctrlClass) . '@data'; |
|
59 | 59 | } |
60 | 60 | |
61 | 61 | return [$controllerMethod, $ctrlClass]; |
@@ -13,8 +13,8 @@ |
||
13 | 13 | */ |
14 | 14 | public function normalize($widget): void |
15 | 15 | { |
16 | - if (! property_exists($widget, 'cacheLifeTime')) { |
|
17 | - $widget->cacheLifeTime = (int) (config('widgetize.default_cache_lifetime', 0)); |
|
16 | + if (!property_exists($widget, 'cacheLifeTime')) { |
|
17 | + $widget->cacheLifeTime = (int)(config('widgetize.default_cache_lifetime', 0)); |
|
18 | 18 | } |
19 | 19 | |
20 | 20 | if ($widget->cacheLifeTime === 'forever' || $widget->cacheLifeTime < 0) { |
@@ -17,7 +17,7 @@ discard block |
||
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 | } |
@@ -27,8 +27,8 @@ discard block |
||
27 | 27 | */ |
28 | 28 | private function checkPresentMethodExists($presenter) : void |
29 | 29 | { |
30 | - if (! method_exists($presenter, 'present')) { |
|
31 | - throw new \InvalidArgumentException("'present' method not found on : ".$presenter); |
|
30 | + if (!method_exists($presenter, 'present')) { |
|
31 | + throw new \InvalidArgumentException("'present' method not found on : " . $presenter); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | |
@@ -37,7 +37,7 @@ discard block |
||
37 | 37 | */ |
38 | 38 | private function checkPresenterExists($presenter): void |
39 | 39 | { |
40 | - if (! class_exists($presenter)) { |
|
40 | + if (!class_exists($presenter)) { |
|
41 | 41 | throw new \InvalidArgumentException("Presenter Class [{$presenter}] not found."); |
42 | 42 | } |
43 | 43 | } |
@@ -52,8 +52,8 @@ discard block |
||
52 | 52 | $presenter = $widget->presenter; |
53 | 53 | $this->checkPresenterExists($presenter); |
54 | 54 | } else { |
55 | - $presenter = get_class($widget).'Presenter'; |
|
56 | - if (! class_exists($presenter)) { |
|
55 | + $presenter = get_class($widget) . 'Presenter'; |
|
56 | + if (!class_exists($presenter)) { |
|
57 | 57 | $widget->presenter = null; |
58 | 58 | } |
59 | 59 | } |
@@ -30,7 +30,7 @@ discard block |
||
30 | 30 | protected function declareAsSingleton(Container $app) |
31 | 31 | { |
32 | 32 | foreach ($this->singletonClasses as $class) { |
33 | - $app->singleton($class, function () use ($class) { |
|
33 | + $app->singleton($class, function() use ($class) { |
|
34 | 34 | return new $class; |
35 | 35 | }); |
36 | 36 | } |
@@ -38,11 +38,11 @@ discard block |
||
38 | 38 | |
39 | 39 | public function registerSingletons(Container $app) |
40 | 40 | { |
41 | - $app->singleton('command.imanghafoori.widget', function (Container $app) { |
|
41 | + $app->singleton('command.imanghafoori.widget', function(Container $app) { |
|
42 | 42 | return $app['Imanghafoori\Widgets\WidgetGenerator']; |
43 | 43 | }); |
44 | 44 | |
45 | - $app->singleton(Normalizer::class, function () { |
|
45 | + $app->singleton(Normalizer::class, function() { |
|
46 | 46 | $normalizer = new Utils\Normalizer(); |
47 | 47 | $normalizer->addNormalizer(new CacheNormalizer()); |
48 | 48 | $normalizer->addNormalizer(new TemplateNormalizer()); |
@@ -15,10 +15,10 @@ discard block |
||
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 |
||
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 | ]); |