Passed
Pull Request — master (#157)
by
unknown
04:13
created
src/MailEclipse.php 1 patch
Spacing   +37 added lines, -37 removed lines patch added patch discarded remove patch
@@ -75,7 +75,7 @@  discard block
 block discarded – undo
75 75
             ->where('template_slug', $templateSlug)->first();
76 76
 
77 77
         if ($template !== null) {
78
-            self::saveTemplates(self::getTemplates()->reject(function ($value) use ($template) {
78
+            self::saveTemplates(self::getTemplates()->reject(function($value) use ($template) {
79 79
                 return $value->template_slug === $template->template_slug;
80 80
             }));
81 81
 
@@ -103,9 +103,9 @@  discard block
 block discarded – undo
103 103
     public static function getTemplatesFile()
104 104
     {
105 105
         $file = config('maileclipse.mailables_dir').'templates.json';
106
-        if (! file_exists($file)) {
107
-            if (! file_exists(config('maileclipse.mailables_dir'))) {
108
-                if (! mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && ! is_dir($concurrentDirectory)) {
106
+        if (!file_exists($file)) {
107
+            if (!file_exists(config('maileclipse.mailables_dir'))) {
108
+                if (!mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && !is_dir($concurrentDirectory)) {
109 109
                     throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory));
110 110
                 }
111 111
             }
@@ -135,7 +135,7 @@  discard block
 block discarded – undo
135 135
             ->where('template_slug', $request->templateslug)->first();
136 136
 
137 137
         if ($template !== null) {
138
-            if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) {
138
+            if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) {
139 139
                 return response()->json([
140 140
                     'status' => 'failed',
141 141
                     'message' => 'Template name not valid',
@@ -154,7 +154,7 @@  discard block
 block discarded – undo
154 154
             }
155 155
 
156 156
             // Update
157
-            $oldForm = self::getTemplates()->reject(function ($value) use ($template) {
157
+            $oldForm = self::getTemplates()->reject(function($value) use ($template) {
158 158
                 return $value->template_slug === $template->template_slug;
159 159
             });
160 160
             $newForm = array_merge($oldForm->toArray(), [array_merge((array) $template, [
@@ -237,7 +237,7 @@  discard block
 block discarded – undo
237 237
      */
238 238
     public static function createTemplate($request): JsonResponse
239 239
     {
240
-        if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) {
240
+        if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) {
241 241
             return response()->json([
242 242
                 'status' => 'error',
243 243
                 'message' => 'Template name not valid',
@@ -248,7 +248,7 @@  discard block
 block discarded – undo
248 248
         $view = self::VIEW_NAMESPACE.'::templates.'.$request->template_name;
249 249
         $templateName = Str::camel(preg_replace('/\s+/', '_', $request->template_name));
250 250
 
251
-        if (! view()->exists($view) && ! self::getTemplates()->contains('template_slug', '=', $templateName)) {
251
+        if (!view()->exists($view) && !self::getTemplates()->contains('template_slug', '=', $templateName)) {
252 252
             self::saveTemplates(self::getTemplates()
253 253
                 ->push([
254 254
                     'template_name' => $request->template_name,
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
 
262 262
             $dir = resource_path('views/vendor/'.self::VIEW_NAMESPACE.'/templates');
263 263
 
264
-            if (! File::isDirectory($dir)) {
264
+            if (!File::isDirectory($dir)) {
265 265
                 File::makeDirectory($dir, 0755, true);
266 266
             }
267 267
 
@@ -301,7 +301,7 @@  discard block
 block discarded – undo
301 301
 
302 302
         $replaced = Replacer::toBlade($content);
303 303
 
304
-        if (! $save) {
304
+        if (!$save) {
305 305
             return $replaced;
306 306
         }
307 307
 
@@ -398,7 +398,7 @@  discard block
 block discarded – undo
398 398
             ]);
399 399
         }
400 400
 
401
-        if (! $request->has('force') && ! self::getMailable('name', $name)->isEmpty()) {
401
+        if (!$request->has('force') && !self::getMailable('name', $name)->isEmpty()) {
402 402
             return response()->json([
403 403
                 'status' => 'error',
404 404
                 'message' => 'This mailable name already exists. names should be unique! to override it, enable "force" option.',
@@ -451,7 +451,7 @@  discard block
 block discarded – undo
451 451
     {
452 452
         $fqcns = [];
453 453
 
454
-        if (! file_exists(config('maileclipse.mailables_dir'))) {
454
+        if (!file_exists(config('maileclipse.mailables_dir'))) {
455 455
             return;
456 456
         } else {
457 457
             $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(config('maileclipse.mailables_dir')));
@@ -464,7 +464,7 @@  discard block
 block discarded – undo
464 464
                 $tokens = token_get_all($content);
465 465
                 $namespace = '';
466 466
                 for ($index = 0; isset($tokens[$index]); $index++) {
467
-                    if (! isset($tokens[$index][0])) {
467
+                    if (!isset($tokens[$index][0])) {
468 468
                         continue;
469 469
                     }
470 470
                     if (T_NAMESPACE === $tokens[$index][0]) {
@@ -480,7 +480,7 @@  discard block
 block discarded – undo
480 480
 
481 481
                         $mailableClass = $namespace.'\\'.$tokens[$index][1];
482 482
 
483
-                        if (! self::mailable_exists($mailableClass)) {
483
+                        if (!self::mailable_exists($mailableClass)) {
484 484
                             continue;
485 485
                         }
486 486
 
@@ -492,7 +492,7 @@  discard block
 block discarded – undo
492 492
 
493 493
                         $mailable_data = self::buildMailable($mailableClass);
494 494
 
495
-                        if (! is_null(self::handleMailableViewDataArgs($mailableClass))) {
495
+                        if (!is_null(self::handleMailableViewDataArgs($mailableClass))) {
496 496
                             $mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data);
497 497
                         } else {
498 498
                             $mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data);
@@ -513,16 +513,16 @@  discard block
 block discarded – undo
513 513
                         $fqcns[$i]['view_path'] = null;
514 514
                         $fqcns[$i]['text_view_path'] = null;
515 515
 
516
-                        if (! is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) {
516
+                        if (!is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) {
517 517
                             $fqcns[$i]['view_path'] = View($fqcns[$i]['markdown'])->getPath();
518 518
                         }
519 519
 
520
-                        if (! is_null($fqcns[$i]['data'])) {
521
-                            if (! is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) {
520
+                        if (!is_null($fqcns[$i]['data'])) {
521
+                            if (!is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) {
522 522
                                 $fqcns[$i]['view_path'] = View($fqcns[$i]['data']->view)->getPath();
523 523
                             }
524 524
 
525
-                            if (! is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) {
525
+                            if (!is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) {
526 526
                                 $fqcns[$i]['text_view_path'] = View($fqcns[$i]['data']->textView)->getPath();
527 527
                                 $fqcns[$i]['text_view'] = $fqcns[$i]['data']->textView;
528 528
                             }
@@ -535,10 +535,10 @@  discard block
 block discarded – undo
535 535
                 }
536 536
             }
537 537
 
538
-            $collection = collect($fqcns)->map(function ($mailable) {
538
+            $collection = collect($fqcns)->map(function($mailable) {
539 539
                 return $mailable;
540
-            })->reject(function ($object) {
541
-                return ! method_exists($object['namespace'], 'build');
540
+            })->reject(function($object) {
541
+                return !method_exists($object['namespace'], 'build');
542 542
             });
543 543
 
544 544
             return $collection;
@@ -562,7 +562,7 @@  discard block
 block discarded – undo
562 562
 
563 563
             $eloquentFactory = app(EloquentFactory::class);
564 564
 
565
-            $args = collect($params)->map(function ($param) {
565
+            $args = collect($params)->map(function($param) {
566 566
                 if ($param->getType() !== null) {
567 567
                     if (class_exists($param->getType()->getName())) {
568 568
                         $parameters = [
@@ -642,17 +642,17 @@  discard block
 block discarded – undo
642 642
         $reflection = collect($params)->where('name', $arg)->first()->getType();
643 643
 
644 644
         if (version_compare(phpversion(), '7.1', '>=')) {
645
-            $type = ! is_null($reflection)
645
+            $type = !is_null($reflection)
646 646
                 ? self::TYPES[$reflection->getName()]
647 647
                 : null;
648 648
         } else {
649
-            $type = ! is_null($reflection)
649
+            $type = !is_null($reflection)
650 650
                 ? self::TYPES[/** @scrutinizer ignore-deprecated */ $reflection->__toString()]
651 651
                 : null;
652 652
         }
653 653
 
654 654
         try {
655
-            return ! is_null($type)
655
+            return !is_null($type)
656 656
                     ? $type
657 657
                     : new Mocked($arg, \ReeceM\Mocker\Utils\VarStore::singleton());
658 658
         } catch (\Exception $e) {
@@ -683,7 +683,7 @@  discard block
 block discarded – undo
683 683
 
684 684
         foreach ($properties as $prop) {
685 685
             if ($prop->class == $data->getName() || $prop->class == get_parent_class($data->getName()) &&
686
-                    get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && ! $prop->isStatic()) {
686
+                    get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && !$prop->isStatic()) {
687 687
                 $allProps[] = $prop->name;
688 688
             }
689 689
         }
@@ -702,7 +702,7 @@  discard block
 block discarded – undo
702 702
 
703 703
         $mailableData = collect($classProps)->merge($withFuncData);
704 704
 
705
-        $data = $mailableData->map(function ($parameter) use ($mailable_data) {
705
+        $data = $mailableData->map(function($parameter) use ($mailable_data) {
706 706
             return [
707 707
                 'key' => $parameter,
708 708
                 'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null,
@@ -749,7 +749,7 @@  discard block
 block discarded – undo
749 749
      */
750 750
     protected static function mailable_exists($mailable): bool
751 751
     {
752
-        if (! class_exists($mailable)) {
752
+        if (!class_exists($mailable)) {
753 753
             return false;
754 754
         }
755 755
 
@@ -807,17 +807,17 @@  discard block
 block discarded – undo
807 807
      */
808 808
     public static function renderPreview($simpleview, $view, $template = false, $instance = null)
809 809
     {
810
-        if (! View::exists($view)) {
810
+        if (!View::exists($view)) {
811 811
             return;
812 812
         }
813 813
 
814
-        if (! $template) {
814
+        if (!$template) {
815 815
             $obj = self::buildMailable($instance);
816 816
             $viewData = $obj->viewData;
817 817
             $_data = array_merge($instance->buildViewData(), $viewData);
818 818
 
819 819
             foreach ($_data as $key => $value) {
820
-                if (! is_object($value)) {
820
+                if (!is_object($value)) {
821 821
                     $_data[$key] = '<span class="maileclipse-key" title="Variable">'.$key.'</span>';
822 822
                 }
823 823
             }
@@ -883,7 +883,7 @@  discard block
 block discarded – undo
883 883
         /**
884 884
          * Removal of reserved keywords.
885 885
          */
886
-        if (! preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) ||
886
+        if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) ||
887 887
             substr_compare($name, $suffix, -strlen($suffix), strlen($suffix), true) !== 0
888 888
         ) {
889 889
             return false;
@@ -902,7 +902,7 @@  discard block
 block discarded – undo
902 902
      */
903 903
     private static function resolveFactory($eloquentFactory, $model): ?object
904 904
     {
905
-        if (! config('maileclipse.factory')) {
905
+        if (!config('maileclipse.factory')) {
906 906
             return app($model);
907 907
         }
908 908
 
@@ -950,9 +950,9 @@  discard block
 block discarded – undo
950 950
         collect((new ReflectionClass($factoryModel))->getMethods())
951 951
             ->pluck('name')
952 952
             ->diff(collect($model->getMethods())->pluck('name'))
953
-            ->filter(function ($method) use ($factoryModel) {
953
+            ->filter(function($method) use ($factoryModel) {
954 954
                 return rescue(
955
-                    function () use ($factoryModel, $method) {
955
+                    function() use ($factoryModel, $method) {
956 956
                         $parents = class_parents($factoryModel->$method());
957 957
 
958 958
                         return isset($parents["Illuminate\Database\Eloquent\Relations\Relation"]);
@@ -961,7 +961,7 @@  discard block
 block discarded – undo
961 961
                     false
962 962
                 );
963 963
             })
964
-            ->each(function ($relationName) use (&$factoryModel, $eloquentFactory) {
964
+            ->each(function($relationName) use (&$factoryModel, $eloquentFactory) {
965 965
                 $factoryModel = self::loadRelations($relationName, $factoryModel, $eloquentFactory);
966 966
             });
967 967
 
Please login to merge, or discard this patch.