runningUnitTests() || $throw) { throw $e; } if ($log) { Log::error('Failed attempt', ['error' => $e]); } return null; } } function attempt_if($condition, callable $callback, bool $log = true): mixed { return value($condition) ? attempt($callback, $log) : null; } function attempt_unless($condition, callable $callback, bool $log = true): mixed { return !value($condition) ? attempt($callback, $log) : null; } function gravatar(string $email, int $size = 192): string { return sprintf("https://www.gravatar.com/avatar/%s?s=$size&d=robohash", md5(Str::lower($email))); } /** * A quick check to determine if a mailer is configured. * This is not bulletproof but should work in most cases. */ function mailer_configured(): bool { return config('mail.default') && !in_array(config('mail.default'), ['log', 'array'], true); } /** @return array */ function collect_sso_providers(): array { if (License::isCommunity()) { return []; } $providers = []; if ( config('services.google.client_id') && config('services.google.client_secret') && config('services.google.hd') ) { $providers[] = 'Google'; } return $providers; }