From 095fb6de41f334d8d794801b1173f9ce41420e98 Mon Sep 17 00:00:00 2001 From: Irfaq Syed Date: Wed, 16 Oct 2024 19:08:47 +0530 Subject: [PATCH] Drop 8.1. Refactor Telegram Class. --- .github/workflows/tests.yml | 2 +- src/Telegram.php | 16 ++++------------ 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index aa7de4f..b316479 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -15,7 +15,7 @@ jobs: strategy: fail-fast: true matrix: - php: ['8.1', '8.2', '8.3'] + php: ['8.2', '8.3'] dependencies: [lowest, highest] experimental: [false] diff --git a/src/Telegram.php b/src/Telegram.php index 4da7f78..f1efbde 100644 --- a/src/Telegram.php +++ b/src/Telegram.php @@ -14,22 +14,14 @@ */ class Telegram { - /** @var HttpClient HTTP Client */ - protected readonly HttpClient $http; - - /** @var null|string Telegram Bot API Token. */ - protected ?string $token; - /** @var string Telegram Bot API Base URI */ protected string $apiBaseUri; public function __construct( - ?string $token = null, - HttpClient $httpClient = new HttpClient, + protected ?string $token = null, + protected HttpClient $http = new HttpClient, string $apiBaseUri = 'https://api.telegram.org' ) { - $this->token = $token; - $this->http = $httpClient; $this->setApiBaseUri($apiBaseUri); } @@ -115,9 +107,9 @@ public function sendMessage(array $params): ?ResponseInterface * * @throws CouldNotSendNotification */ - public function sendFile(array $params, string|array $type, bool $multipart = false): ?ResponseInterface + public function sendFile(array $params, string $type, bool $multipart = false): ?ResponseInterface { - return $this->sendRequest('send'.Str::studly((array) $type[0]), $params, $multipart); + return $this->sendRequest('send'.Str::studly($type), $params, $multipart); } /**