@@ -79,7 +79,7 @@ discard block |
||
| 79 | 79 | ->where('template_slug', $templateSlug)->first(); |
| 80 | 80 | |
| 81 | 81 | if ($template !== null) { |
| 82 | - self::saveTemplates(self::getTemplates()->reject(function ($value) use ($template) { |
|
| 82 | + self::saveTemplates(self::getTemplates()->reject(function($value) use ($template) { |
|
| 83 | 83 | return $value->template_slug === $template->template_slug; |
| 84 | 84 | })); |
| 85 | 85 | |
@@ -107,9 +107,9 @@ discard block |
||
| 107 | 107 | public static function getTemplatesFile() |
| 108 | 108 | { |
| 109 | 109 | $file = config('maileclipse.mailables_dir').'templates.json'; |
| 110 | - if (! file_exists($file)) { |
|
| 111 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 112 | - if (! mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && ! is_dir($concurrentDirectory)) { |
|
| 110 | + if (!file_exists($file)) { |
|
| 111 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 112 | + if (!mkdir($concurrentDirectory = config('maileclipse.mailables_dir')) && !is_dir($concurrentDirectory)) { |
|
| 113 | 113 | throw new \RuntimeException(sprintf('Directory "%s" was not created', $concurrentDirectory)); |
| 114 | 114 | } |
| 115 | 115 | } |
@@ -139,7 +139,7 @@ discard block |
||
| 139 | 139 | ->where('template_slug', $request->templateslug)->first(); |
| 140 | 140 | |
| 141 | 141 | if ($template !== null) { |
| 142 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 142 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->title)) { |
|
| 143 | 143 | return response()->json([ |
| 144 | 144 | 'status' => 'failed', |
| 145 | 145 | 'message' => 'Template name not valid', |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | // Update |
| 161 | - $oldForm = self::getTemplates()->reject(function ($value) use ($template) { |
|
| 161 | + $oldForm = self::getTemplates()->reject(function($value) use ($template) { |
|
| 162 | 162 | return $value->template_slug === $template->template_slug; |
| 163 | 163 | }); |
| 164 | 164 | $newForm = array_merge($oldForm->toArray(), [array_merge((array) $template, [ |
@@ -241,7 +241,7 @@ discard block |
||
| 241 | 241 | */ |
| 242 | 242 | public static function createTemplate($request): JsonResponse |
| 243 | 243 | { |
| 244 | - if (! preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 244 | + if (!preg_match("/^[a-zA-Z0-9-_\s]+$/", $request->template_name)) { |
|
| 245 | 245 | return response()->json([ |
| 246 | 246 | 'status' => 'error', |
| 247 | 247 | 'message' => 'Template name not valid', |
@@ -252,7 +252,7 @@ discard block |
||
| 252 | 252 | $view = self::VIEW_NAMESPACE.'::templates.'.$request->template_name; |
| 253 | 253 | $templateName = Str::camel(preg_replace('/\s+/', '_', $request->template_name)); |
| 254 | 254 | |
| 255 | - if (! view()->exists($view) && ! self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 255 | + if (!view()->exists($view) && !self::getTemplates()->contains('template_slug', '=', $templateName)) { |
|
| 256 | 256 | self::saveTemplates(self::getTemplates() |
| 257 | 257 | ->push([ |
| 258 | 258 | 'template_name' => $request->template_name, |
@@ -265,7 +265,7 @@ discard block |
||
| 265 | 265 | |
| 266 | 266 | $dir = resource_path('views/vendor/'.self::VIEW_NAMESPACE.'/templates'); |
| 267 | 267 | |
| 268 | - if (! File::isDirectory($dir)) { |
|
| 268 | + if (!File::isDirectory($dir)) { |
|
| 269 | 269 | File::makeDirectory($dir, 0755, true); |
| 270 | 270 | } |
| 271 | 271 | |
@@ -305,7 +305,7 @@ discard block |
||
| 305 | 305 | |
| 306 | 306 | $replaced = Replacer::toBlade($content); |
| 307 | 307 | |
| 308 | - if (! $save) { |
|
| 308 | + if (!$save) { |
|
| 309 | 309 | return $replaced; |
| 310 | 310 | } |
| 311 | 311 | |
@@ -398,7 +398,7 @@ discard block |
||
| 398 | 398 | $defaultDirectory = 'Mail'; |
| 399 | 399 | |
| 400 | 400 | $mailableDir = config('maileclipse.mailables_dir'); |
| 401 | - $customPath = substr($mailableDir,strpos($mailableDir,$defaultDirectory) + strlen($defaultDirectory) + 1); |
|
| 401 | + $customPath = substr($mailableDir, strpos($mailableDir, $defaultDirectory) + strlen($defaultDirectory) + 1); |
|
| 402 | 402 | |
| 403 | 403 | if ($name === false) { |
| 404 | 404 | return response()->json([ |
@@ -407,7 +407,7 @@ discard block |
||
| 407 | 407 | ]); |
| 408 | 408 | } |
| 409 | 409 | |
| 410 | - if (! $request->has('force') && ! self::getMailable('name', $name)->isEmpty()) { |
|
| 410 | + if (!$request->has('force') && !self::getMailable('name', $name)->isEmpty()) { |
|
| 411 | 411 | return response()->json([ |
| 412 | 412 | 'status' => 'error', |
| 413 | 413 | 'message' => 'This mailable name already exists. names should be unique! to override it, enable "force" option.', |
@@ -463,7 +463,7 @@ discard block |
||
| 463 | 463 | { |
| 464 | 464 | $fqcns = []; |
| 465 | 465 | |
| 466 | - if (! file_exists(config('maileclipse.mailables_dir'))) { |
|
| 466 | + if (!file_exists(config('maileclipse.mailables_dir'))) { |
|
| 467 | 467 | return; |
| 468 | 468 | } else { |
| 469 | 469 | $allFiles = new RecursiveIteratorIterator(new RecursiveDirectoryIterator(config('maileclipse.mailables_dir'))); |
@@ -476,7 +476,7 @@ discard block |
||
| 476 | 476 | $tokens = token_get_all($content); |
| 477 | 477 | $namespace = ''; |
| 478 | 478 | for ($index = 0; isset($tokens[$index]); $index++) { |
| 479 | - if (! isset($tokens[$index][0])) { |
|
| 479 | + if (!isset($tokens[$index][0])) { |
|
| 480 | 480 | continue; |
| 481 | 481 | } |
| 482 | 482 | if (T_NAMESPACE === $tokens[$index][0]) { |
@@ -492,7 +492,7 @@ discard block |
||
| 492 | 492 | |
| 493 | 493 | $mailableClass = $namespace.'\\'.$tokens[$index][1]; |
| 494 | 494 | |
| 495 | - if (! self::mailable_exists($mailableClass)) { |
|
| 495 | + if (!self::mailable_exists($mailableClass)) { |
|
| 496 | 496 | continue; |
| 497 | 497 | } |
| 498 | 498 | |
@@ -504,7 +504,7 @@ discard block |
||
| 504 | 504 | |
| 505 | 505 | $mailable_data = self::buildMailable($mailableClass); |
| 506 | 506 | |
| 507 | - if (! is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 507 | + if (!is_null(self::handleMailableViewDataArgs($mailableClass))) { |
|
| 508 | 508 | $mailable_view_data = self::getMailableViewData(self::handleMailableViewDataArgs($mailableClass), $mailable_data); |
| 509 | 509 | } else { |
| 510 | 510 | $mailable_view_data = self::getMailableViewData(new $mailableClass, $mailable_data); |
@@ -525,16 +525,16 @@ discard block |
||
| 525 | 525 | $fqcns[$i]['view_path'] = null; |
| 526 | 526 | $fqcns[$i]['text_view_path'] = null; |
| 527 | 527 | |
| 528 | - if (! is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 528 | + if (!is_null($fqcns[$i]['markdown']) && View::exists($fqcns[$i]['markdown'])) { |
|
| 529 | 529 | $fqcns[$i]['view_path'] = View($fqcns[$i]['markdown'])->getPath(); |
| 530 | 530 | } |
| 531 | 531 | |
| 532 | - if (! is_null($fqcns[$i]['data'])) { |
|
| 533 | - if (! is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 532 | + if (!is_null($fqcns[$i]['data'])) { |
|
| 533 | + if (!is_null($fqcns[$i]['data']->view) && View::exists($fqcns[$i]['data']->view)) { |
|
| 534 | 534 | $fqcns[$i]['view_path'] = View($fqcns[$i]['data']->view)->getPath(); |
| 535 | 535 | } |
| 536 | 536 | |
| 537 | - if (! is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 537 | + if (!is_null($fqcns[$i]['data']->textView) && View::exists($fqcns[$i]['data']->textView)) { |
|
| 538 | 538 | $fqcns[$i]['text_view_path'] = View($fqcns[$i]['data']->textView)->getPath(); |
| 539 | 539 | $fqcns[$i]['text_view'] = $fqcns[$i]['data']->textView; |
| 540 | 540 | } |
@@ -547,10 +547,10 @@ discard block |
||
| 547 | 547 | } |
| 548 | 548 | } |
| 549 | 549 | |
| 550 | - $collection = collect($fqcns)->map(function ($mailable) { |
|
| 550 | + $collection = collect($fqcns)->map(function($mailable) { |
|
| 551 | 551 | return $mailable; |
| 552 | - })->reject(function ($object) { |
|
| 553 | - return ! method_exists($object['namespace'], 'build'); |
|
| 552 | + })->reject(function($object) { |
|
| 553 | + return !method_exists($object['namespace'], 'build'); |
|
| 554 | 554 | }); |
| 555 | 555 | |
| 556 | 556 | return $collection; |
@@ -576,7 +576,7 @@ discard block |
||
| 576 | 576 | |
| 577 | 577 | $eloquentFactory = app(EloquentFactory::class); |
| 578 | 578 | |
| 579 | - $args = collect($params)->map(function ($param) { |
|
| 579 | + $args = collect($params)->map(function($param) { |
|
| 580 | 580 | if ($param->getType() !== null) { |
| 581 | 581 | if (class_exists($param->getType()->getName())) { |
| 582 | 582 | $parameters = [ |
@@ -695,7 +695,7 @@ discard block |
||
| 695 | 695 | |
| 696 | 696 | foreach ($properties as $prop) { |
| 697 | 697 | if ($prop->class == $data->getName() || $prop->class == get_parent_class($data->getName()) && |
| 698 | - get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && ! $prop->isStatic()) { |
|
| 698 | + get_parent_class($data->getName()) != 'Illuminate\Mail\Mailable' && !$prop->isStatic()) { |
|
| 699 | 699 | $allProps[] = $prop->name; |
| 700 | 700 | } |
| 701 | 701 | } |
@@ -714,7 +714,7 @@ discard block |
||
| 714 | 714 | |
| 715 | 715 | $mailableData = collect($classProps)->merge($withFuncData); |
| 716 | 716 | |
| 717 | - $data = $mailableData->map(function ($parameter) use ($mailable_data) { |
|
| 717 | + $data = $mailableData->map(function($parameter) use ($mailable_data) { |
|
| 718 | 718 | return [ |
| 719 | 719 | 'key' => $parameter, |
| 720 | 720 | 'value' => property_exists($mailable_data, $parameter) ? $mailable_data->$parameter : null, |
@@ -761,7 +761,7 @@ discard block |
||
| 761 | 761 | */ |
| 762 | 762 | protected static function mailable_exists($mailable): bool |
| 763 | 763 | { |
| 764 | - if (! class_exists($mailable)) { |
|
| 764 | + if (!class_exists($mailable)) { |
|
| 765 | 765 | return false; |
| 766 | 766 | } |
| 767 | 767 | |
@@ -822,17 +822,17 @@ discard block |
||
| 822 | 822 | */ |
| 823 | 823 | public static function renderPreview($simpleview, $view, $template = false, $instance = null) |
| 824 | 824 | { |
| 825 | - if (! View::exists($view)) { |
|
| 825 | + if (!View::exists($view)) { |
|
| 826 | 826 | return; |
| 827 | 827 | } |
| 828 | 828 | |
| 829 | - if (! $template) { |
|
| 829 | + if (!$template) { |
|
| 830 | 830 | $obj = self::buildMailable($instance); |
| 831 | 831 | $viewData = $obj->viewData; |
| 832 | 832 | $_data = array_merge($instance->buildViewData(), $viewData); |
| 833 | 833 | |
| 834 | 834 | foreach ($_data as $key => $value) { |
| 835 | - if (! is_object($value)) { |
|
| 835 | + if (!is_object($value)) { |
|
| 836 | 836 | $_data[$key] = '<span class="maileclipse-key" title="Variable">'.$key.'</span>'; |
| 837 | 837 | } |
| 838 | 838 | } |
@@ -898,7 +898,7 @@ discard block |
||
| 898 | 898 | /** |
| 899 | 899 | * Removal of reserved keywords. |
| 900 | 900 | */ |
| 901 | - if (! preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 901 | + if (!preg_match('/^[a-zA-Z_\x80-\xff][a-zA-Z0-9_\x80-\xff]*$/', $name) || |
|
| 902 | 902 | substr_compare($name, $suffix, -strlen($suffix), strlen($suffix), true) !== 0 |
| 903 | 903 | ) { |
| 904 | 904 | return false; |
@@ -918,7 +918,7 @@ discard block |
||
| 918 | 918 | */ |
| 919 | 919 | private static function resolveFactory($eloquentFactory, $model): ?object |
| 920 | 920 | { |
| 921 | - if (! config('maileclipse.factory')) { |
|
| 921 | + if (!config('maileclipse.factory')) { |
|
| 922 | 922 | return app($model); |
| 923 | 923 | } |
| 924 | 924 | |
@@ -963,15 +963,15 @@ discard block |
||
| 963 | 963 | self::$traversed += 1; |
| 964 | 964 | |
| 965 | 965 | collect((new ReflectionClass($factoryModel))->getMethods()) |
| 966 | - ->filter(function (\ReflectionMethod $method) use ($model) { |
|
| 967 | - return ! $model->hasMethod($method->getName()); |
|
| 966 | + ->filter(function(\ReflectionMethod $method) use ($model) { |
|
| 967 | + return !$model->hasMethod($method->getName()); |
|
| 968 | 968 | }) |
| 969 | - ->filter(function (\ReflectionMethod $method) use ($factoryModel) { |
|
| 969 | + ->filter(function(\ReflectionMethod $method) use ($factoryModel) { |
|
| 970 | 970 | if ($method->getNumberOfParameters() >= 1) { |
| 971 | 971 | return false; |
| 972 | 972 | } |
| 973 | 973 | |
| 974 | - $parents = rescue(function () use ($method, $factoryModel) { |
|
| 974 | + $parents = rescue(function() use ($method, $factoryModel) { |
|
| 975 | 975 | $methodName = $method->getName(); |
| 976 | 976 | |
| 977 | 977 | return $method->hasReturnType() |
@@ -981,7 +981,7 @@ discard block |
||
| 981 | 981 | |
| 982 | 982 | return isset($parents["Illuminate\Database\Eloquent\Relations\Relation"]); |
| 983 | 983 | }) |
| 984 | - ->each(function (\ReflectionMethod $relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 984 | + ->each(function(\ReflectionMethod $relationName) use (&$factoryModel, $eloquentFactory) { |
|
| 985 | 985 | $factoryModel = self::loadRelations($relationName->getName(), $factoryModel, $eloquentFactory); |
| 986 | 986 | }); |
| 987 | 987 | |
@@ -1010,7 +1010,7 @@ discard block |
||
| 1010 | 1010 | $relatedFactory = self::resolveFactory($eloquentFactory, get_class($related)); |
| 1011 | 1011 | |
| 1012 | 1012 | if (self::$traversed <= config('maileclipse.relations.relation_depth')) { |
| 1013 | - if (! $loadIfIterable) { |
|
| 1013 | + if (!$loadIfIterable) { |
|
| 1014 | 1014 | $relatedFactory = self::hydrateRelations($eloquentFactory, $relatedFactory); |
| 1015 | 1015 | } else { |
| 1016 | 1016 | $models = collect(); |