1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2025-12-14 16:44:03 +00:00

resolve all phpstan issues

This commit is contained in:
Samuel Štancl 2022-11-08 13:34:04 +01:00
parent b7a6953231
commit 942d79cbd7
12 changed files with 57 additions and 88 deletions

View file

@ -9,27 +9,14 @@ use Illuminate\Database\Eloquent\Builder;
class ClearPendingTenants extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tenants:pending-clear
{--all : Override the default settings and deletes all pending tenants}
{--older-than-days= : Deletes all pending tenants older than the amount of days}
{--older-than-hours= : Deletes all pending tenants older than the amount of hours}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Remove pending tenants.';
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$this->info('Removing pending tenants.');
@ -39,7 +26,10 @@ class ClearPendingTenants extends Command
// Skip the time constraints if the 'all' option is given
if (! $this->option('all')) {
/** @var ?int $olderThanDays */
$olderThanDays = $this->option('older-than-days');
/** @var ?int $olderThanHours */
$olderThanHours = $this->option('older-than-hours');
if ($olderThanDays && $olderThanHours) {
@ -70,5 +60,7 @@ class ClearPendingTenants extends Command
->count();
$this->info($deletedTenantCount . ' pending ' . str('tenant')->plural($deletedTenantCount) . ' deleted.');
return 0;
}
}

View file

@ -8,24 +8,11 @@ use Illuminate\Console\Command;
class CreatePendingTenants extends Command
{
/**
* The name and signature of the console command.
*
* @var string
*/
protected $signature = 'tenants:pending-create {--count= : The number of pending tenants to be created}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Create pending tenants.';
/**
* Execute the console command.
*/
public function handle()
public function handle(): int
{
$this->info('Creating pending tenants.');
@ -46,13 +33,11 @@ class CreatePendingTenants extends Command
$this->info($createdCount . ' ' . str('tenant')->plural($createdCount) . ' created.');
$this->info($maxPendingTenantCount . ' ' . str('tenant')->plural($maxPendingTenantCount) . ' ready to be used.');
return 1;
return 0;
}
/**
* Calculate the number of currently available pending tenants.
*/
private function getPendingTenantCount(): int
/** Calculate the number of currently available pending tenants. */
protected function getPendingTenantCount(): int
{
return tenancy()
->query()

View file

@ -117,6 +117,7 @@ class Install extends Command
$this->newLine();
}
} else {
/** @var string $warning */
$this->components->warn($warning);
}
}

View file

@ -4,12 +4,12 @@ declare(strict_types=1);
namespace Stancl\Tenancy\Commands;
use Illuminate\Console\Command;
use Illuminate\Database\Console\Migrations\BaseCommand;
use Stancl\Tenancy\Concerns\DealsWithMigrations;
use Stancl\Tenancy\Concerns\HasTenantOptions;
use Symfony\Component\Console\Input\InputOption;
class MigrateFresh extends Command
class MigrateFresh extends BaseCommand
{
use HasTenantOptions, DealsWithMigrations;