File tree Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Expand file tree Collapse file tree 1 file changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -12,21 +12,22 @@ class ReadFromTextFileCredentials extends Auth
12
12
* @param string $fileName
13
13
* @param int $readInterval
14
14
*/
15
- public function __construct (string $ fileName = "token.json " , int $ readInterval = 600 )
15
+ public function __construct (string $ fileName = "token.txt " , int $ readInterval = 60 )
16
16
{
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 ' " );
19
19
}
20
20
$ this ->fileName = $ fileName ;
21
21
$ this ->readInterval = $ readInterval ;
22
22
}
23
23
24
24
public function getTokenInfo (): TokenInfo
25
25
{
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 ' " );
28
29
}
29
- $ token = preg_filter ( ' /\s+|\n/ ' , "" , file_get_contents ( $ this -> fileName ) );
30
+ $ token = trim ( $ token );
30
31
return new TokenInfo ($ token , $ this ->readInterval , 1 );
31
32
}
32
33
You can’t perform that action at this time.
0 commit comments