generated from open-southeners/php-package-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
28 changed files
with
1,472 additions
and
68 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,52 +1,65 @@ | ||
{ | ||
"name": "open-southeners/packagist_package_here", | ||
"description": "and_description_here", | ||
"license": "MIT", | ||
"keywords": [ | ||
"open-southeners" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Ruben Robles", | ||
"email": "[email protected]", | ||
"homepage": "https://d8vjork.com" | ||
} | ||
], | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/open-southeners" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1" | ||
}, | ||
"require-dev": { | ||
"larastan/larastan": "^2.0", | ||
"orchestra/testbench": "^8.0 || ^9.0", | ||
"phpstan/phpstan": "^1.0", | ||
"phpunit/phpunit": "^10.0" | ||
}, | ||
"minimum-stability": "stable", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"OpenSoutheners\\PhpPackage\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"OpenSoutheners\\PhpPackage\\Tests\\": "tests" | ||
} | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
"name": "open-southeners/packagist_package_here", | ||
"description": "and_description_here", | ||
"license": "MIT", | ||
"keywords": [ | ||
"open-southeners", | ||
"laravel", | ||
"utilities", | ||
"php8", | ||
"php" | ||
], | ||
"authors": [ | ||
{ | ||
"name": "Ruben Robles", | ||
"email": "[email protected]", | ||
"homepage": "https://d8vjork.com" | ||
} | ||
], | ||
"funding": [ | ||
{ | ||
"type": "github", | ||
"url": "https://github.com/sponsors/open-southeners" | ||
} | ||
], | ||
"require": { | ||
"php": "^8.1", | ||
"open-southeners/byte-unit-converter": "^3.0", | ||
"open-southeners/extended-php": "^1.0" | ||
}, | ||
"require-dev": { | ||
"larastan/larastan": "^2.0", | ||
"laravel/cashier": "^15.0", | ||
"laravel/passport": "^12.0", | ||
"laravel/pint": "^1.5", | ||
"laravel/socialite": "^5.0", | ||
"orchestra/testbench": "^8.0 || ^9.0", | ||
"phpstan/phpstan": "^1.0", | ||
"phpunit/phpunit": "^10.0" | ||
}, | ||
"minimum-stability": "stable", | ||
"prefer-stable": true, | ||
"autoload": { | ||
"psr-4": { | ||
"OpenSoutheners\\ExtendedLaravel\\": "src" | ||
} | ||
}, | ||
"autoload-dev": { | ||
"psr-4": { | ||
"OpenSoutheners\\ExtendedLaravel\\Tests\\": "tests" | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"OpenSoutheners\\PhpPackage\\ServiceProvider" | ||
] | ||
} | ||
"files": [ | ||
"src/Models/functions.php" | ||
] | ||
}, | ||
"config": { | ||
"sort-packages": true | ||
}, | ||
"extra": { | ||
"laravel": { | ||
"providers": [ | ||
"OpenSoutheners\\ExtendedLaravel\\ServiceProvider" | ||
] | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?php | ||
|
||
namespace OpenSoutheners\ExtendedLaravel; | ||
|
||
use Illuminate\Foundation\Console\AboutCommand; | ||
use Illuminate\Support\Facades\Storage; | ||
use Illuminate\Support\Str; | ||
use Laravel\Cashier\Cashier; | ||
use Laravel\Passport\Passport; | ||
use Laravel\Socialite\Contracts\Factory; | ||
use ReflectionClass; | ||
use Stripe\Stripe; | ||
|
||
class AboutCommandIntegration | ||
{ | ||
public static function register() | ||
{ | ||
if (! class_exists(AboutCommand::class)) { | ||
return; | ||
} | ||
|
||
(new static) | ||
->printExtendedDriversInfo() | ||
->printIntegrationsInfo() | ||
->printCashierInfo(); | ||
} | ||
|
||
private function getUserConfigured(string $variable, string $value): string | ||
{ | ||
$userConfiguredValue = env($variable); | ||
|
||
if (! empty($userConfiguredValue)) { | ||
return sprintf('<fg=yellow;options=bold>%s</>', $value); | ||
} | ||
|
||
return $value; | ||
} | ||
|
||
public function printExtendedDriversInfo(): self | ||
{ | ||
AboutCommand::add('Drivers', fn (): array => [ | ||
'Storage' => $this->getUserConfigured('FILESYSTEM_DISK', Storage::getDefaultDriver()), | ||
]); | ||
|
||
return $this; | ||
} | ||
|
||
public function printIntegrationsInfo(): self | ||
{ | ||
AboutCommand::add('Integrations', function (): array { | ||
$integrations = []; | ||
|
||
if (class_exists(Factory::class)) { | ||
$socialiteManager = app(Factory::class); | ||
|
||
$providers = array_keys((new ReflectionClass($socialiteManager)) | ||
->getProperty('customCreators') | ||
->getValue($socialiteManager)); | ||
|
||
$integrations['Socialite'] = sprintf( | ||
'%s %s', | ||
! empty($providers) ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>', | ||
! empty($providers) ? Str::wrap(implode(', ', $providers), '(', ')') : '' | ||
); | ||
} | ||
|
||
if (class_exists(Passport::class)) { | ||
$integrations['Passport'] = ( | ||
! empty(env('PASSPORT_PRIVATE_KEY')) && ! empty(env('PASSPORT_PUBLIC_KEY')) | ||
|| (Passport::keyPath('oauth-public.key') && Passport::keyPath('oauth-private.key') | ||
)) ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>'; | ||
} | ||
|
||
return $integrations; | ||
}); | ||
|
||
return $this; | ||
} | ||
|
||
public function printCashierInfo(): self | ||
{ | ||
$cashierDriver = match (true) { | ||
class_exists('Laravel\Cashier\Cashier') => 'Stripe', | ||
class_exists('Laravel\Paddle\Cashier') => 'Paddle', | ||
default => false, | ||
}; | ||
|
||
if (! $cashierDriver) { | ||
return $this; | ||
} | ||
|
||
AboutCommand::add('Cashier', function () use ($cashierDriver): array { | ||
$infoArray = [ | ||
'Driver' => $cashierDriver, | ||
'Cashier version' => Cashier::VERSION, | ||
'Customer model' => Cashier::$customerModel, | ||
'Enables routes' => Cashier::$registersRoutes ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>', | ||
'Enables taxes' => Cashier::$calculatesTaxes ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>', | ||
'Enables incomplete subscriptions' => Cashier::$deactivateIncomplete ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>', | ||
'Enables past due subscriptions' => Cashier::$deactivatePastDue ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>', | ||
]; | ||
|
||
if ($cashierDriver === 'Stripe') { | ||
$infoArray['Enabled'] = Cashier::stripe()->getApiKey() ? '<fg=green;options=bold>YES</>' : '<fg=yellow;options=bold>NO</>'; | ||
$infoArray['Stripe SDK version'] = Stripe::VERSION; | ||
$infoArray['Stripe API version'] = Cashier::STRIPE_VERSION; | ||
} | ||
|
||
return $infoArray; | ||
}); | ||
|
||
return $this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?php | ||
|
||
namespace OpenSoutheners\ExtendedLaravel\Console\Commands; | ||
|
||
use Illuminate\Console\Command; | ||
use Illuminate\Support\Arr; | ||
use Illuminate\Support\Carbon; | ||
use Illuminate\Support\Facades\DB; | ||
|
||
class BatchesQueueCommand extends Command | ||
{ | ||
/** | ||
* The name and signature of the console command. | ||
* | ||
* @var string | ||
*/ | ||
protected $signature = 'queue:batches'; | ||
|
||
/** | ||
* The console command description. | ||
* | ||
* @var string | ||
*/ | ||
protected $description = 'List queued job batches'; | ||
|
||
/** | ||
* Execute the console command. | ||
*/ | ||
public function handle(): int | ||
{ | ||
$columns = ['id', 'name', 'completion', 'total_jobs', 'pending_jobs', 'failed_job_ids', 'created_at', 'finished_at']; | ||
|
||
$this->table( | ||
Arr::exceptValues($columns, ['total_jobs', 'pending_jobs']), | ||
DB::connection(config('queue.batching.database')) | ||
->table(config('queue.batching.table', 'job_batches')) | ||
Check failure on line 36 in src/Console/Commands/BatchesQueueCommand.php GitHub Actions / PHPStan
|
||
->get(Arr::exceptValues($columns, ['completion'])) | ||
->map(function (\stdClass $jobBatch) { | ||
Check failure on line 38 in src/Console/Commands/BatchesQueueCommand.php GitHub Actions / PHPStan
|
||
$jobBatch = (array) $jobBatch; | ||
|
||
$jobBatch['total_jobs'] = sprintf('%d%%', $jobBatch['pending_jobs'] / $jobBatch['total_jobs'] * 100); | ||
|
||
unset($jobBatch['pending_jobs']); | ||
|
||
$jobBatch['created_at'] = Carbon::createFromTimestamp($jobBatch['created_at']); | ||
|
||
if ($jobBatch['finished_at']) { | ||
$jobBatch['finished_at'] = Carbon::createFromTimestamp($jobBatch['finished_at']); | ||
} | ||
|
||
return $jobBatch; | ||
}) | ||
->all(), | ||
); | ||
|
||
return 0; | ||
} | ||
} |
Oops, something went wrong.