Completed
Push — master ( 566ab8...d28f05 )
by
unknown
14s queued 11s
created
src/MailEclipse.php 1 patch
Spacing   +35 added lines, -35 removed lines patch added patch discarded remove patch
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
             ->where('template_slug', $templateSlug)->first();
81 81
 
82 82
         if ($template !== null) {
83
-            self::saveTemplates(self::getTemplates()->reject(function ($value) use ($template) {
83
+            self::saveTemplates(self::getTemplates()->reject(function($value) use ($template) {
84 84
                 return $value->template_slug === $template->template_slug;
85 85
             }));
86 86
 
@@ -108,9 +108,9 @@  discard block
 block discarded – undo
108 108
     public static function getTemplatesFile()
109 109
     {
110 110
         $file = config('maileclipse.mailables_dir').'templates.json';
111
-        if (! file_exists($file)) {
112
-            if (! file_exists(config('maileclipse.mailables_dir'))) {
113
-                if (! mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && ! is_dir($concurrentDirectory)) {
111
+        if (!file_exists($file)) {
112
+            if (!file_exists(config('maileclipse.mailables_dir'))) {
113
+                if (!mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && !is_dir($concurrentDirectory)) {
114 114
                     throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
115 115
                 }
116 116
             }
@@ -140,7 +140,7 @@  discard block
 block discarded – undo
140 140
             ->where('template_slug', $request->templateslug)->first();
141 141
 
142 142
         if ($template !== null) {
143
-            if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) {
143
+            if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) {
144 144
                 return response()->json([
145 145
                     'status' => 'failed',
146 146
                     'message' => 'Template name not valid',
@@ -159,7 +159,7 @@  discard block
 block discarded – undo
159 159
             }
160 160
 
161 161
             // Update
162
-            $oldForm = self::getTemplates()->reject(function ($value) use ($template) {
162
+            $oldForm = self::getTemplates()->reject(function($value) use ($template) {
163 163
                 return $value->template_slug === $template->template_slug;
164 164
             });
165 165
             $newForm = array_merge($oldForm->toArray(), [array_merge((array) $template, [
@@ -242,7 +242,7 @@  discard block
 block discarded – undo
242 242
      */
243 243
     public static function createTemplate($request): JsonResponse
244 244
     {
245
-        if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) {
245
+        if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) {
246 246
             return response()->json([
247 247
                 'status' => 'error',
248 248
                 'message' => 'Template name not valid',
@@ -253,7 +253,7 @@  discard block
 block discarded – undo
253 253
         $view = self::VIEW_NAMESPACE.'::templates.'.$request->template_name;
254 254
         $templateName = Str::camel(preg_replace('/\s+/', '_', $request->template_name));
255 255
 
256
-        if (! view()->exists($view) && ! self::getTemplates()->contains('template_slug', '=', $templateName)) {
256
+        if (!view()->exists($view) && !self::getTemplates()->contains('template_slug', '=', $templateName)) {
257 257
             self::saveTemplates(self::getTemplates()
258 258
                 ->push([
259 259
                     'template_name' => $request->template_name,
@@ -266,7 +266,7 @@  discard block
 block discarded – undo
266 266
 
267 267
             $dir = resource_path('views/vendor/'.self::VIEW_NAMESPACE.'/templates');
268 268
 
269
-            if (! File::isDirectory($dir)) {
269
+            if (!File::isDirectory($dir)) {
270 270
                 File::makeDirectory($dir, 0755, true);
271 271
             }
272 272
 
@@ -306,7 +306,7 @@  discard block
 block discarded – undo
306 306
 
307 307
         $replaced = Replacer::toBlade($content);
308 308
 
309
-        if (! $save) {
309
+        if (!$save) {
310 310
             return $replaced;
311 311
         }
312 312
 
@@ -404,7 +404,7 @@  discard block
 block discarded – undo
404 404
             ]);
405 405
         }
406 406
 
407
-        if (! $request->has('force') && ! self::getMailable('name', $name)->isEmpty()) {
407
+        if (!$request->has('force') && !self::getMailable('name', $name)->isEmpty()) {
408 408
             return response()->json([
409 409
                 'status' => 'error',
410 410
                 'message' => 'This mailable name already exists. names should be unique! to override it, enable "force" option.',
@@ -458,7 +458,7 @@  discard block
 block discarded – undo
458 458
     {
459 459
         $fqcns = [];
460 460
 
461
-        if (! file_exists(config('maileclipse.mailables_dir'))) {
461
+        if (!file_exists(config('maileclipse.mailables_dir'))) {
462 462
             return;
463 463
         } else {
464 464
             $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(config('maileclipse.mailables_dir')));
@@ -471,7 +471,7 @@  discard block
 block discarded – undo
471 471
                 $tokens = token_get_all($content);
472 472
                 $namespace = '';
473 473
                 for ($index = 0; isset($tokens[$index]); $index++) {
474
-                    if (! isset($tokens[$index][0])) {
474
+                    if (!isset($tokens[$index][0])) {
475 475
                         continue;
476 476
                     }
477 477
                     if (T_NAMESPACE === $tokens[$index][0]) {
@@ -487,7 +487,7 @@  discard block
 block discarded – undo
487 487
 
488 488
                         $mailableClass = $namespace.'\\'.$tokens[$index][1];
489 489
 
490
-                        if (! self::mailable_exists($mailableClass)) {
490
+                        if (!self::mailable_exists($mailableClass)) {
491 491
                             continue;
492 492
                         }
493 493
 
@@ -499,7 +499,7 @@  discard block
 block discarded – undo
499 499
 
500 500
                         $mailable_data = self::buildMailable($mailableClass);
501 501
 
502
-                        if (! is_null(self::handleMailableViewDataArgs($mailableClass))) {
502
+                        if (!is_null(self::handleMailableViewDataArgs($mailableClass))) {
503 503
                             $mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data);
504 504
                         } else {
505 505
                             $mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data);
@@ -520,16 +520,16 @@  discard block
 block discarded – undo
520 520
                         $fqcns[$i]['view_path'] = null;
521 521
                         $fqcns[$i]['text_view_path'] = null;
522 522
 
523
-                        if (! is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) {
523
+                        if (!is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) {
524 524
                             $fqcns[$i]['view_path'] = View($fqcns[$i]['markdown'])->getPath();
525 525
                         }
526 526
 
527
-                        if (! is_null($fqcns[$i]['data'])) {
528
-                            if (! is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) {
527
+                        if (!is_null($fqcns[$i]['data'])) {
528
+                            if (!is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) {
529 529
                                 $fqcns[$i]['view_path'] = View($fqcns[$i]['data']->view)->getPath();
530 530
                             }
531 531
 
532
-                            if (! is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) {
532
+                            if (!is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) {
533 533
                                 $fqcns[$i]['text_view_path'] = View($fqcns[$i]['data']->textView)->getPath();
534 534
                                 $fqcns[$i]['text_view'] = $fqcns[$i]['data']->textView;
535 535
                             }
@@ -542,10 +542,10 @@  discard block
 block discarded – undo
542 542
                 }
543 543
             }
544 544
 
545
-            $collection = collect($fqcns)->map(function ($mailable) {
545
+            $collection = collect($fqcns)->map(function($mailable) {
546 546
                 return $mailable;
547
-            })->reject(function ($object) {
548
-                return ! method_exists($object['namespace'], 'build');
547
+            })->reject(function($object) {
548
+                return !method_exists($object['namespace'], 'build');
549 549
             });
550 550
 
551 551
             return $collection;
@@ -571,7 +571,7 @@  discard block
 block discarded – undo
571 571
 
572 572
             $eloquentFactory = app(EloquentFactory::class);
573 573
 
574
-            $args = collect($params)->map(function ($param) {
574
+            $args = collect($params)->map(function($param) {
575 575
                 if ($param->getType() !== null) {
576 576
                     if (class_exists($param->getType()->getName())) {
577 577
                         $parameters = [
@@ -690,7 +690,7 @@  discard block
 block discarded – undo
690 690
 
691 691
         foreach ($properties as $prop) {
692 692
             if ($prop->class == $data->getName() || $prop->class == get_parent_class($data->getName()) &&
693
-                    get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && ! $prop->isStatic()) {
693
+                    get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && !$prop->isStatic()) {
694 694
                 $allProps[] = $prop->name;
695 695
             }
696 696
         }
@@ -709,7 +709,7 @@  discard block
 block discarded – undo
709 709
 
710 710
         $mailableData = collect($classProps)->merge($withFuncData);
711 711
 
712
-        $data = $mailableData->map(function ($parameter) use ($mailable_data) {
712
+        $data = $mailableData->map(function($parameter) use ($mailable_data) {
713 713
             return [
714 714
                 'key' => $parameter,
715 715
                 'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null,
@@ -756,7 +756,7 @@  discard block
 block discarded – undo
756 756
      */
757 757
     protected static function mailable_exists($mailable): bool
758 758
     {
759
-        if (! class_exists($mailable)) {
759
+        if (!class_exists($mailable)) {
760 760
             return false;
761 761
         }
762 762
 
@@ -817,17 +817,17 @@  discard block
 block discarded – undo
817 817
      */
818 818
     public static function renderPreview($simpleview, $view, $template = false, $instance = null)
819 819
     {
820
-        if (! View::exists($view)) {
820
+        if (!View::exists($view)) {
821 821
             return;
822 822
         }
823 823
 
824
-        if (! $template) {
824
+        if (!$template) {
825 825
             $obj = self::buildMailable($instance);
826 826
             $viewData = $obj->viewData;
827 827
             $_data = array_merge($instance->buildViewData(), $viewData);
828 828
 
829 829
             foreach ($_data as $key => $value) {
830
-                if (! is_object($value)) {
830
+                if (!is_object($value)) {
831 831
                     $_data[$key] = '<span class="maileclipse-key" title="Variable">'.$key.'</span>';
832 832
                 }
833 833
             }
@@ -893,7 +893,7 @@  discard block
 block discarded – undo
893 893
         /**
894 894
          * Removal of reserved keywords.
895 895
          */
896
-        if (! preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) ||
896
+        if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) ||
897 897
             substr_compare($name, $suffix, -strlen($suffix), strlen($suffix), true) !== 0
898 898
         ) {
899 899
             return false;
@@ -913,7 +913,7 @@  discard block
 block discarded – undo
913 913
      */
914 914
     private static function resolveFactory($eloquentFactory, $model): ?object
915 915
     {
916
-        if (! config('maileclipse.factory')) {
916
+        if (!config('maileclipse.factory')) {
917 917
             return app($model);
918 918
         }
919 919
 
@@ -960,9 +960,9 @@  discard block
 block discarded – undo
960 960
         collect((new ReflectionClass($factoryModel))->getMethods())
961 961
             ->pluck('name')
962 962
             ->diff(collect($model->getMethods())->pluck('name'))
963
-            ->filter(function ($method) use ($factoryModel) {
963
+            ->filter(function($method) use ($factoryModel) {
964 964
                 return rescue(
965
-                    function () use ($factoryModel, $method) {
965
+                    function() use ($factoryModel, $method) {
966 966
                         $parents = class_parents($factoryModel->$method());
967 967
 
968 968
                         return isset($parents["Illuminate\Database\Eloquent\Relations\Relation"]);
@@ -971,7 +971,7 @@  discard block
 block discarded – undo
971 971
                     false
972 972
                 );
973 973
             })
974
-            ->each(function ($relationName) use (&$factoryModel, $eloquentFactory) {
974
+            ->each(function($relationName) use (&$factoryModel, $eloquentFactory) {
975 975
                 $factoryModel = self::loadRelations($relationName, $factoryModel, $eloquentFactory);
976 976
             });
977 977
 
@@ -1000,7 +1000,7 @@  discard block
 block discarded – undo
1000 1000
                 $relatedFactory = self::resolveFactory($eloquentFactory, get_class($related));
1001 1001
 
1002 1002
                 if (self::$traversed <= config('maileclipse.relation_depth')) {
1003
-                    if (! $loadIfIterable) {
1003
+                    if (!$loadIfIterable) {
1004 1004
                         $relatedFactory = self::hydrateRelations($eloquentFactory, $relatedFactory);
1005 1005
                     } else {
1006 1006
                         $models = collect();
Please login to merge, or discard this patch.