@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | ->where('template_slug', $templateSlug)->first(); |
| 79 | 79 | |
| 80 | 80 | if ($template !== null) { |
| 81 | - self::saveTemplates(self::getTemplates()->reject(function ($value) use ($template) { |
|
| 81 | + self::saveTemplates(self::getTemplates()->reject(function($value) use ($template) { |
|
| 82 | 82 | return $value->template_slug === $template->template_slug; |
| 83 | 83 | })); |
| 84 | 84 | |
@@ -106,9 +106,9 @@ discard block |
||
| 106 | 106 | public static function getTemplatesFile() |
| 107 | 107 | { |
| 108 | 108 | $file = config('maileclipse.mailables_dir').'templates.json'; |
| 109 | - if (! file_exists($file)) { |
|
| 110 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 111 | - if (! mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && ! is_dir($concurrentDirectory)) { |
|
| 109 | + if (!file_exists($file)) { |
|
| 110 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 111 | + if (!mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && !is_dir($concurrentDirectory)) { |
|
| 112 | 112 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); |
| 113 | 113 | } |
| 114 | 114 | } |
@@ -138,7 +138,7 @@ discard block |
||
| 138 | 138 | ->where('template_slug', $request->templateslug)->first(); |
| 139 | 139 | |
| 140 | 140 | if ($template !== null) { |
| 141 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 141 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 142 | 142 | return response()->json([ |
| 143 | 143 | 'status' => 'failed', |
| 144 | 144 | 'message' => 'Template name not valid', |
@@ -157,7 +157,7 @@ discard block |
||
| 157 | 157 | } |
| 158 | 158 | |
| 159 | 159 | // Update |
| 160 | - $oldForm = self::getTemplates()->reject(function ($value) use ($template) { |
|
| 160 | + $oldForm = self::getTemplates()->reject(function($value) use ($template) { |
|
| 161 | 161 | return $value->template_slug === $template->template_slug; |
| 162 | 162 | }); |
| 163 | 163 | $newForm = array_merge($oldForm->toArray(), [array_merge((array) $template, [ |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | */ |
| 241 | 241 | public static function createTemplate($request): JsonResponse |
| 242 | 242 | { |
| 243 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 243 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 244 | 244 | return response()->json([ |
| 245 | 245 | 'status' => 'error', |
| 246 | 246 | 'message' => 'Template name not valid', |
@@ -251,7 +251,7 @@ discard block |
||
| 251 | 251 | $view = self::VIEW_NAMESPACE.'::templates.'.$request->template_name; |
| 252 | 252 | $templateName = Str::camel(preg_replace('/\s+/', '_', $request->template_name)); |
| 253 | 253 | |
| 254 | - if (! view()->exists($view) && ! self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 254 | + if (!view()->exists($view) && !self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 255 | 255 | self::saveTemplates(self::getTemplates() |
| 256 | 256 | ->push([ |
| 257 | 257 | 'template_name' => $request->template_name, |
@@ -264,7 +264,7 @@ discard block |
||
| 264 | 264 | |
| 265 | 265 | $dir = resource_path('views/vendor/'.self::VIEW_NAMESPACE.'/templates'); |
| 266 | 266 | |
| 267 | - if (! File::isDirectory($dir)) { |
|
| 267 | + if (!File::isDirectory($dir)) { |
|
| 268 | 268 | File::makeDirectory($dir, 0755, true); |
| 269 | 269 | } |
| 270 | 270 | |
@@ -304,7 +304,7 @@ discard block |
||
| 304 | 304 | |
| 305 | 305 | $replaced = Replacer::toBlade($content); |
| 306 | 306 | |
| 307 | - if (! $save) { |
|
| 307 | + if (!$save) { |
|
| 308 | 308 | return $replaced; |
| 309 | 309 | } |
| 310 | 310 | |
@@ -401,7 +401,7 @@ discard block |
||
| 401 | 401 | ]); |
| 402 | 402 | } |
| 403 | 403 | |
| 404 | - if (! $request->has('force') && ! self::getMailable('name', $name)->isEmpty()) { |
|
| 404 | + if (!$request->has('force') && !self::getMailable('name', $name)->isEmpty()) { |
|
| 405 | 405 | return response()->json([ |
| 406 | 406 | 'status' => 'error', |
| 407 | 407 | 'message' => 'This mailable name already exists. names should be unique! to override it, enable "force" option.', |
@@ -454,7 +454,7 @@ discard block |
||
| 454 | 454 | { |
| 455 | 455 | $fqcns = []; |
| 456 | 456 | |
| 457 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 457 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 458 | 458 | return; |
| 459 | 459 | } else { |
| 460 | 460 | $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(config('maileclipse.mailables_dir'))); |
@@ -467,7 +467,7 @@ discard block |
||
| 467 | 467 | $tokens = token_get_all($content); |
| 468 | 468 | $namespace = ''; |
| 469 | 469 | for ($index = 0; isset($tokens[$index]); $index++) { |
| 470 | - if (! isset($tokens[$index][0])) { |
|
| 470 | + if (!isset($tokens[$index][0])) { |
|
| 471 | 471 | continue; |
| 472 | 472 | } |
| 473 | 473 | if (T_NAMESPACE === $tokens[$index][0]) { |
@@ -483,7 +483,7 @@ discard block |
||
| 483 | 483 | |
| 484 | 484 | $mailableClass = $namespace.'\\'.$tokens[$index][1]; |
| 485 | 485 | |
| 486 | - if (! self::mailable_exists($mailableClass)) { |
|
| 486 | + if (!self::mailable_exists($mailableClass)) { |
|
| 487 | 487 | continue; |
| 488 | 488 | } |
| 489 | 489 | |
@@ -495,7 +495,7 @@ discard block |
||
| 495 | 495 | |
| 496 | 496 | $mailable_data = self::buildMailable($mailableClass); |
| 497 | 497 | |
| 498 | - if (! is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 498 | + if (!is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 499 | 499 | $mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data); |
| 500 | 500 | } else { |
| 501 | 501 | $mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data); |
@@ -516,16 +516,16 @@ discard block |
||
| 516 | 516 | $fqcns[$i]['view_path'] = null; |
| 517 | 517 | $fqcns[$i]['text_view_path'] = null; |
| 518 | 518 | |
| 519 | - if (! is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 519 | + if (!is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 520 | 520 | $fqcns[$i]['view_path'] = View($fqcns[$i]['markdown'])->getPath(); |
| 521 | 521 | } |
| 522 | 522 | |
| 523 | - if (! is_null($fqcns[$i]['data'])) { |
|
| 524 | - if (! is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 523 | + if (!is_null($fqcns[$i]['data'])) { |
|
| 524 | + if (!is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 525 | 525 | $fqcns[$i]['view_path'] = View($fqcns[$i]['data']->view)->getPath(); |
| 526 | 526 | } |
| 527 | 527 | |
| 528 | - if (! is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 528 | + if (!is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 529 | 529 | $fqcns[$i]['text_view_path'] = View($fqcns[$i]['data']->textView)->getPath(); |
| 530 | 530 | $fqcns[$i]['text_view'] = $fqcns[$i]['data']->textView; |
| 531 | 531 | } |
@@ -538,10 +538,10 @@ discard block |
||
| 538 | 538 | } |
| 539 | 539 | } |
| 540 | 540 | |
| 541 | - $collection = collect($fqcns)->map(function ($mailable) { |
|
| 541 | + $collection = collect($fqcns)->map(function($mailable) { |
|
| 542 | 542 | return $mailable; |
| 543 | - })->reject(function ($object) { |
|
| 544 | - return ! method_exists($object['namespace'], 'build'); |
|
| 543 | + })->reject(function($object) { |
|
| 544 | + return !method_exists($object['namespace'], 'build'); |
|
| 545 | 545 | }); |
| 546 | 546 | |
| 547 | 547 | return $collection; |
@@ -565,7 +565,7 @@ discard block |
||
| 565 | 565 | |
| 566 | 566 | $eloquentFactory = app(EloquentFactory::class); |
| 567 | 567 | |
| 568 | - $args = collect($params)->map(function ($param) { |
|
| 568 | + $args = collect($params)->map(function($param) { |
|
| 569 | 569 | if ($param->getType() !== null) { |
| 570 | 570 | if (class_exists($param->getType()->getName())) { |
| 571 | 571 | $parameters = [ |
@@ -647,7 +647,7 @@ discard block |
||
| 647 | 647 | try { |
| 648 | 648 | |
| 649 | 649 | if (is_null($reflection)) { |
| 650 | - return new Mocked($arg, \ReeceM\Mocker\Utils\VarStore::singleton());; |
|
| 650 | + return new Mocked($arg, \ReeceM\Mocker\Utils\VarStore::singleton()); ; |
|
| 651 | 651 | } |
| 652 | 652 | |
| 653 | 653 | $type = version_compare(phpversion(), '7.1', '>=') |
@@ -685,7 +685,7 @@ discard block |
||
| 685 | 685 | |
| 686 | 686 | foreach ($properties as $prop) { |
| 687 | 687 | if ($prop->class == $data->getName() || $prop->class == get_parent_class($data->getName()) && |
| 688 | - get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && ! $prop->isStatic()) { |
|
| 688 | + get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && !$prop->isStatic()) { |
|
| 689 | 689 | $allProps[] = $prop->name; |
| 690 | 690 | } |
| 691 | 691 | } |
@@ -704,7 +704,7 @@ discard block |
||
| 704 | 704 | |
| 705 | 705 | $mailableData = collect($classProps)->merge($withFuncData); |
| 706 | 706 | |
| 707 | - $data = $mailableData->map(function ($parameter) use ($mailable_data) { |
|
| 707 | + $data = $mailableData->map(function($parameter) use ($mailable_data) { |
|
| 708 | 708 | return [ |
| 709 | 709 | 'key' => $parameter, |
| 710 | 710 | 'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null, |
@@ -751,7 +751,7 @@ discard block |
||
| 751 | 751 | */ |
| 752 | 752 | protected static function mailable_exists($mailable): bool |
| 753 | 753 | { |
| 754 | - if (! class_exists($mailable)) { |
|
| 754 | + if (!class_exists($mailable)) { |
|
| 755 | 755 | return false; |
| 756 | 756 | } |
| 757 | 757 | |
@@ -809,17 +809,17 @@ discard block |
||
| 809 | 809 | */ |
| 810 | 810 | public static function renderPreview($simpleview, $view, $template = false, $instance = null) |
| 811 | 811 | { |
| 812 | - if (! View::exists($view)) { |
|
| 812 | + if (!View::exists($view)) { |
|
| 813 | 813 | return; |
| 814 | 814 | } |
| 815 | 815 | |
| 816 | - if (! $template) { |
|
| 816 | + if (!$template) { |
|
| 817 | 817 | $obj = self::buildMailable($instance); |
| 818 | 818 | $viewData = $obj->viewData; |
| 819 | 819 | $_data = array_merge($instance->buildViewData(), $viewData); |
| 820 | 820 | |
| 821 | 821 | foreach ($_data as $key => $value) { |
| 822 | - if (! is_object($value)) { |
|
| 822 | + if (!is_object($value)) { |
|
| 823 | 823 | $_data[$key] = '<span class="maileclipse-key" title="Variable">'.$key.'</span>'; |
| 824 | 824 | } |
| 825 | 825 | } |
@@ -885,7 +885,7 @@ discard block |
||
| 885 | 885 | /** |
| 886 | 886 | * Removal of reserved keywords. |
| 887 | 887 | */ |
| 888 | - if (! preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 888 | + if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 889 | 889 | substr_compare($name, $suffix, -strlen($suffix), strlen($suffix), true) !== 0 |
| 890 | 890 | ) { |
| 891 | 891 | return false; |
@@ -906,7 +906,7 @@ discard block |
||
| 906 | 906 | */ |
| 907 | 907 | private static function resolveFactory($eloquentFactory, $model): ?object |
| 908 | 908 | { |
| 909 | - if (! config('maileclipse.factory')) { |
|
| 909 | + if (!config('maileclipse.factory')) { |
|
| 910 | 910 | return app($model); |
| 911 | 911 | } |
| 912 | 912 | |
@@ -954,9 +954,9 @@ discard block |
||
| 954 | 954 | collect((new ReflectionClass($factoryModel))->getMethods()) |
| 955 | 955 | ->pluck('name') |
| 956 | 956 | ->diff(collect($model->getMethods())->pluck('name')) |
| 957 | - ->filter(function ($method) use ($factoryModel) { |
|
| 957 | + ->filter(function($method) use ($factoryModel) { |
|
| 958 | 958 | return rescue( |
| 959 | - function () use ($factoryModel, $method) { |
|
| 959 | + function() use ($factoryModel, $method) { |
|
| 960 | 960 | $parents = class_parents($factoryModel->$method()); |
| 961 | 961 | |
| 962 | 962 | return isset($parents["Illuminate\Database\Eloquent\Relations\Relation"]); |
@@ -965,7 +965,7 @@ discard block |
||
| 965 | 965 | false |
| 966 | 966 | ); |
| 967 | 967 | }) |
| 968 | - ->each(function ($relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 968 | + ->each(function($relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 969 | 969 | $factoryModel = self::loadRelations($relationName, $factoryModel, $eloquentFactory); |
| 970 | 970 | }); |
| 971 | 971 | |
@@ -995,7 +995,7 @@ discard block |
||
| 995 | 995 | $relatedFactory = self::resolveFactory($eloquentFactory, get_class($related)); |
| 996 | 996 | |
| 997 | 997 | if (self::$traversed <= config('maileclipse.relation_depth')) { |
| 998 | - if (! $loadIfIterable) { |
|
| 998 | + if (!$loadIfIterable) { |
|
| 999 | 999 | $relatedFactory = self::hydrateRelations($eloquentFactory, $relatedFactory); |
| 1000 | 1000 | } else { |
| 1001 | 1001 | $models = collect(); |