get('driver')) { case 's3': $credentials = $this->amazonRules(); break; case 'doSpaces': $credentials = $this->spacesRules(); break; case 'dropbox': $credentials = $this->dropboxRules(); break; } return array_merge($credentials, [ 'name' => ['required'], 'driver' => ['required'], ]); } /** * Amazon S3 proper. The endpoint is optional here -- leaving it out means * the region alone decides which host the SDK talks to. */ private function amazonRules(): array { return [ 'credentials.key' => ['required', 'string'], 'credentials.secret' => ['required', 'string'], 'credentials.region' => ['required', 'string'], 'credentials.bucket' => ['required', 'string'], 'credentials.endpoint' => ['nullable', 'string', 'url', new PublicHttpUrl], 'credentials.root' => ['required', 'string'], ]; } /** * DigitalOcean Spaces speaks the S3 protocol but always against its own * host, so the endpoint is mandatory rather than optional. */ private function spacesRules(): array { return [ 'credentials.key' => ['required', 'string'], 'credentials.secret' => ['required', 'string'], 'credentials.region' => ['required', 'string'], 'credentials.bucket' => ['required', 'string'], 'credentials.endpoint' => ['required', 'string', 'url', new PublicHttpUrl], 'credentials.root' => ['required', 'string'], ]; } /** * Dropbox: an access token plus the app identity it was issued for. No * endpoint, so nothing for the reachability rule to inspect. */ private function dropboxRules(): array { return [ 'credentials.token' => ['required', 'string'], 'credentials.key' => ['required', 'string'], 'credentials.secret' => ['required', 'string'], 'credentials.app' => ['required', 'string'], 'credentials.root' => ['required', 'string'], ]; } }