Skip to content

Commit 1702df6

Browse files
author
Илья
committed
Set default read interval 60 seconds
1 parent bbf7661 commit 1702df6

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/Auth/ReadFromTextFileCredentials.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@ class ReadFromTextFileCredentials extends Auth
1212
* @param string $fileName
1313
* @param int $readInterval
1414
*/
15-
public function __construct(string $fileName = "token.json", int $readInterval = 600)
15+
public function __construct(string $fileName = "token.txt", int $readInterval = 60)
1616
{
17-
if(!file_exists($fileName)){
18-
throw new \Exception("File $fileName is not exists");
17+
if(file_get_contents($fileName)===false){
18+
throw new \Exception("Error reading the file '$fileName'");
1919
}
2020
$this->fileName = $fileName;
2121
$this->readInterval = $readInterval;
2222
}
2323

2424
public function getTokenInfo(): TokenInfo
2525
{
26-
if(!file_exists($this->fileName)){
27-
throw new \Exception("File $this->fileName is not exists");
26+
$token = file_get_contents($this->fileName);
27+
if($token===false){
28+
throw new \Exception("Error reading the file '$this->fileName'");
2829
}
29-
$token = preg_filter('/\s+|\n/', "", file_get_contents($this->fileName));
30+
$token = trim($token);
3031
return new TokenInfo($token, $this->readInterval, 1);
3132
}
3233

0 commit comments

Comments
 (0)