From e5a947e973fad06c6b38bf3bd7a7e0e932e4e821 Mon Sep 17 00:00:00 2001 From: flashwave Date: Wed, 26 Feb 2025 15:14:30 +0000 Subject: [PATCH] Moved user agent string creation thingy into a method. --- src/ATProto/XrpcClient.php | 2 +- src/Misuzu.php | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/ATProto/XrpcClient.php b/src/ATProto/XrpcClient.php index 385a2f7b..72cda2b9 100644 --- a/src/ATProto/XrpcClient.php +++ b/src/ATProto/XrpcClient.php @@ -20,7 +20,7 @@ class XrpcClient { 'base_uri' => sprintf('%s/xrpc/', rtrim($service, '/')), 'timeout' => 10, 'headers' => [ - 'User-Agent' => sprintf('Misuzu/%s', Misuzu::version()), + 'User-Agent' => Misuzu::userAgent(), ], ]); } diff --git a/src/Misuzu.php b/src/Misuzu.php index 7ad32fe1..77d8496c 100644 --- a/src/Misuzu.php +++ b/src/Misuzu.php @@ -36,6 +36,10 @@ final class Misuzu { return trim($version); } + public static function userAgent(): string { + return sprintf('%s/%s', __NAMESPACE__, self::version()); + } + public static function debug(): bool { return !empty(ini_get('display_errors')); }