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
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
You can’t perform that action at this time.
0 commit comments