Skip to content

Commit f2b2297

Browse files
committed
Add all variables as members and add DocBlocks.
1 parent 818027b commit f2b2297

File tree

2 files changed

+59
-14
lines changed

2 files changed

+59
-14
lines changed

src/BotManager.php

Lines changed: 57 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,51 @@ class BotManager
6363
*/
6464
public $selfcrt;
6565

66+
/**
67+
* @var array Array of logger files to set
68+
*/
69+
public $logging;
70+
71+
/**
72+
* @var array List of admins to enable
73+
*/
74+
public $admins;
75+
76+
/**
77+
* @var array MySQL credentials to use
78+
*/
79+
public $mysql;
80+
81+
/**
82+
* @var string Custom download path to set
83+
*/
84+
public $download_path;
85+
86+
/**
87+
* @var string Custom upload path to set
88+
*/
89+
public $upload_path;
90+
91+
/**
92+
* @var array Custom commands paths to set
93+
*/
94+
public $commands_paths;
95+
96+
/**
97+
* @var array List of custom command configs
98+
*/
99+
public $command_configs;
100+
101+
/**
102+
* @var string Botan token to enable botan.io support
103+
*/
104+
public $botan_token;
105+
106+
/**
107+
* @var string Custom raw JSON string to use as input
108+
*/
109+
public $custom_input;
110+
66111
/**
67112
* @var array List of valid actions that can be called
68113
*/
@@ -182,7 +227,7 @@ public function makeCliFriendly()
182227
*/
183228
public function initLogging()
184229
{
185-
if (isset($this->logging) && is_array($this->logging)) {
230+
if (is_array($this->logging)) {
186231
foreach ($this->logging as $logger => $logfile) {
187232
('debug' === $logger) && TelegramLog::initDebugLog($logfile);
188233
('error' === $logger) && TelegramLog::initErrorLog($logfile);
@@ -260,7 +305,7 @@ public function validateAndSetWebhook()
260305
/**
261306
* Check if the current action is one of the passed ones.
262307
*
263-
* @param $actions
308+
* @param string|array $actions
264309
*
265310
* @return bool
266311
*/
@@ -314,7 +359,7 @@ public function handleRequest()
314359
/**
315360
* Loop the getUpdates method for the passed amount of seconds.
316361
*
317-
* @param $loop_time_in_seconds int
362+
* @param int $loop_time_in_seconds
318363
*
319364
* @return $this
320365
*/
@@ -392,15 +437,15 @@ public function handleWebhook()
392437
*/
393438
public function setBotExtras()
394439
{
395-
isset($this->admins) && $this->telegram->enableAdmins((array)$this->admins);
396-
isset($this->mysql) && $this->telegram->enableMySql($this->mysql);
397-
isset($this->botan_token) && $this->telegram->enableBotan($this->botan_token);
398-
isset($this->commands_paths) && $this->telegram->addCommandsPaths((array)$this->commands_paths);
399-
isset($this->custom_input) && $this->telegram->setCustomInput($this->custom_input);
400-
isset($this->download_path) && $this->telegram->setDownloadPath($this->download_path);
401-
isset($this->upload_path) && $this->telegram->setUploadPath($this->upload_path);
402-
403-
if (isset($this->command_configs) && is_array($this->command_configs)) {
440+
$this->admins && $this->telegram->enableAdmins($this->admins);
441+
$this->mysql && $this->telegram->enableMySql($this->mysql);
442+
$this->botan_token && $this->telegram->enableBotan($this->botan_token);
443+
$this->commands_paths && $this->telegram->addCommandsPaths($this->commands_paths);
444+
$this->custom_input && $this->telegram->setCustomInput($this->custom_input);
445+
$this->download_path && $this->telegram->setDownloadPath($this->download_path);
446+
$this->upload_path && $this->telegram->setUploadPath($this->upload_path);
447+
448+
if (is_array($this->command_configs)) {
404449
foreach ($this->command_configs as $command => $config) {
405450
$this->telegram->setCommandConfig($command, $config);
406451
}

tests/BotManagerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,11 +63,11 @@ public function setUp()
6363
public function testSetParameters()
6464
{
6565
$botManager = new BotManager(array_merge($this->vitalParams, [
66-
'admins' => 1, // valid
66+
'admins' => [1], // valid
6767
'upload_path' => '/upload/path', // valid
6868
'paramX' => 'something' // invalid
6969
]));
70-
self::assertEquals(1, $botManager->admins);
70+
self::assertEquals([1], $botManager->admins);
7171
self::assertEquals('/upload/path', $botManager->upload_path);
7272
self::assertObjectNotHasAttribute('paramX', $botManager);
7373
}

0 commit comments

Comments
 (0)