Lint PHP code psr-12, add GH action

This commit is contained in:
Julien Nahum
2024-02-23 11:54:12 +01:00
parent e85e4df7fe
commit 62971a2ef4
226 changed files with 2338 additions and 2144 deletions

View File

@@ -8,10 +8,12 @@ use Illuminate\Http\Request;
class CustomDomainRequest extends FormRequest
{
const CUSTOM_DOMAINS_REGEX = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,20}$/';
public const CUSTOM_DOMAINS_REGEX = '/^[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,20}$/';
public Workspace $workspace;
public array $customDomains = [];
public function __construct(Request $request, Workspace $workspace)
{
$this->workspace = Workspace::findOrFail($request->workspaceId);
@@ -28,13 +30,13 @@ class CustomDomainRequest extends FormRequest
'custom_domains' => [
'present',
'array',
function($attribute, $value, $fail) {
function ($attribute, $value, $fail) {
$errors = [];
$domains = collect($value)->filter(function ($domain) {
return !empty( trim($domain) );
})->each(function($domain) use (&$errors) {
if (!preg_match(self::CUSTOM_DOMAINS_REGEX, $domain)) {
$errors[] = 'Invalid domain: ' . $domain;
return ! empty(trim($domain));
})->each(function ($domain) use (&$errors) {
if (! preg_match(self::CUSTOM_DOMAINS_REGEX, $domain)) {
$errors[] = 'Invalid domain: '.$domain;
}
});
@@ -44,16 +46,17 @@ class CustomDomainRequest extends FormRequest
$limit = $this->workspace->custom_domain_count_limit;
if ($limit && $domains->count() > $limit) {
$fail('You can only add ' . $limit . ' domain(s).');
$fail('You can only add '.$limit.' domain(s).');
}
$this->customDomains = $domains->toArray();
}
]
},
],
];
}
protected function passedValidation(){
protected function passedValidation()
{
$this->replace(['custom_domains' => $this->customDomains]);
}
}