chore: code refactor via rector
This commit is contained in:
@@ -2,8 +2,8 @@
|
||||
|
||||
namespace App\Livewire\Dashboard;
|
||||
|
||||
use Illuminate\Support\Facades\Session;
|
||||
use Livewire\Component;
|
||||
use Session;
|
||||
|
||||
class BulkGmail extends Component
|
||||
{
|
||||
@@ -13,7 +13,7 @@ class BulkGmail extends Component
|
||||
|
||||
public $bulkEmails = [];
|
||||
|
||||
public function mount()
|
||||
public function mount(): void
|
||||
{
|
||||
$subscriptionCheck = auth()->user()->subscribedToProduct(config('app.plans')[0]['product_id']);
|
||||
Session::put('isSubscribed', $subscriptionCheck);
|
||||
@@ -34,7 +34,7 @@ class BulkGmail extends Component
|
||||
$this->bulkEmails = [];
|
||||
}
|
||||
|
||||
$this->bulkEmails = $this->generateDotVariants(explode('@', $this->email)[0], $this->quantity);
|
||||
$this->bulkEmails = $this->generateDotVariants(explode('@', (string) $this->email)[0], $this->quantity);
|
||||
}
|
||||
|
||||
public function downloadBulk()
|
||||
@@ -47,12 +47,15 @@ class BulkGmail extends Component
|
||||
$filename = 'bulk_gmails_'.now()->format('Ymd_His').'.txt';
|
||||
$content = implode(PHP_EOL, $this->bulkEmails);
|
||||
|
||||
return response()->streamDownload(function () use ($content) {
|
||||
return response()->streamDownload(function () use ($content): void {
|
||||
echo $content;
|
||||
}, $filename);
|
||||
}
|
||||
|
||||
private function generateDotVariants($uname, $quantity)
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
private function generateDotVariants(string $uname, int $quantity): array
|
||||
{
|
||||
$length = strlen($uname);
|
||||
$positions = range(1, $length - 1);
|
||||
@@ -89,7 +92,7 @@ class BulkGmail extends Component
|
||||
return [[]];
|
||||
}
|
||||
|
||||
if (empty($items)) {
|
||||
if ($items === []) {
|
||||
return [];
|
||||
}
|
||||
|
||||
@@ -102,19 +105,14 @@ class BulkGmail extends Component
|
||||
$combinations[] = $c;
|
||||
}
|
||||
|
||||
foreach ($this->combinations($tail, $size) as $c) {
|
||||
$combinations[] = $c;
|
||||
}
|
||||
|
||||
return $combinations;
|
||||
return $this->combinations($tail, $size);
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if (Session::get('isSubscribed')) {
|
||||
return view('livewire.dashboard.bulk-gmail')->layout('components.layouts.dashboard');
|
||||
} else {
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
return view('livewire.dashboard.not-subscribed')->layout('components.layouts.dashboard');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user