server creation wip
This commit is contained in:
22
app/Actions/GenerateRandomSlug.php
Normal file
22
app/Actions/GenerateRandomSlug.php
Normal file
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
class GenerateRandomSlug
|
||||
{
|
||||
public function execute($adjectiveCount = 1): string
|
||||
{
|
||||
$adjectives = explode("\n", file_get_contents(resource_path('text/english-adjectives.txt')));
|
||||
$nouns = explode("\n", file_get_contents(resource_path('text/english-nouns.txt')));
|
||||
|
||||
$slug = '';
|
||||
|
||||
for ($i = 0; $i < $adjectiveCount; $i++) {
|
||||
$slug .= $adjectives[array_rand($adjectives)] . '-';
|
||||
}
|
||||
|
||||
$slug .= $nouns[array_rand($nouns)];
|
||||
|
||||
return $slug;
|
||||
}
|
||||
}
|
||||
17
app/Actions/GetProviderService.php
Normal file
17
app/Actions/GetProviderService.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
|
||||
namespace App\Actions;
|
||||
|
||||
use App\Services\ServerProviders\HetznerService;
|
||||
use App\Services\ServerProviders\ServerProviderService;
|
||||
|
||||
class GetProviderService
|
||||
{
|
||||
public function execute(string $provider): ServerProviderService|null
|
||||
{
|
||||
return match ($provider) {
|
||||
'hetzner' => new HetznerService(),
|
||||
default => null,
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user