Skip to content

Commit a518947

Browse files
committed
Small changes!
1 parent 68acdec commit a518947

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/Botan.php

+3-7
Original file line numberDiff line numberDiff line change
@@ -166,11 +166,7 @@ public static function track(Update $update, $command = '')
166166
}
167167

168168
// In case there is no from field assign id = 0
169-
if (isset($data['from']['id'])) {
170-
$uid = $data['from']['id'];
171-
} else {
172-
$uid = 0;
173-
}
169+
$uid = (isset($data['from']['id'])) ? $data['from']['id'] : 0;
174170

175171
try {
176172
$response = self::$client->post(
@@ -222,7 +218,7 @@ public static function shortenUrl($url, $user_id)
222218
throw new TelegramException('User id is empty!');
223219
}
224220

225-
if ($cached = BotanDB::selectShortUrl($user_id, $url)) {
221+
if ($cached = BotanDB::selectShortUrl($url, $user_id)) {
226222
return $cached;
227223
}
228224

@@ -240,7 +236,7 @@ public static function shortenUrl($url, $user_id)
240236
$result = $e->getMessage();
241237
} finally {
242238
if (filter_var($result, FILTER_VALIDATE_URL) !== false) {
243-
BotanDB::insertShortUrl($user_id, $url, $result);
239+
BotanDB::insertShortUrl($url, $user_id, $result);
244240
return $result;
245241
} else {
246242
TelegramLog::debug('Botan.io URL shortening failed for \'' . $url . '\': ' . ($result ?: 'empty response') . "\n\n");

src/BotanDB.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ public static function initializeBotanDb()
3232
/**
3333
* Select cached shortened URL from the database
3434
*
35-
* @param $user_id
36-
* @param $url
35+
* @param string $url
36+
* @param integer $user_id
3737
*
3838
* @return array|bool
3939
* @throws \Longman\TelegramBot\Exception\TelegramException
4040
*/
41-
public static function selectShortUrl($user_id, $url)
41+
public static function selectShortUrl($url, $user_id)
4242
{
4343
if (!self::isDbConnected()) {
4444
return false;
@@ -65,14 +65,14 @@ public static function selectShortUrl($user_id, $url)
6565
/**
6666
* Insert shortened URL into the database
6767
*
68-
* @param $user_id
69-
* @param $url
70-
* @param $short_url
68+
* @param string $url
69+
* @param integer $user_id
70+
* @param string $short_url
7171
*
7272
* @return bool
7373
* @throws \Longman\TelegramBot\Exception\TelegramException
7474
*/
75-
public static function insertShortUrl($user_id, $url, $short_url)
75+
public static function insertShortUrl($url, $user_id, $short_url)
7676
{
7777
if (!self::isDbConnected()) {
7878
return false;

0 commit comments

Comments
 (0)