File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed
Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -12,19 +12,25 @@ final class GetStargazersCount
1212 public function __construct (
1313 private HttpClient $ httpClient ,
1414 private Cache $ cache ,
15- ) {}
15+ ) {
16+ }
1617
1718 public function __invoke (): ?string
1819 {
1920 return $ this ->cache ->resolve (
2021 key: 'tempest-stargazers ' ,
2122 cache: function () {
22- $ body = $ this ->httpClient ->get ('https://api.github.com/repos/tempestphp/tempest-framework ' )->body ;
23- $ stargazers = json_decode ($ body )->stargazers_count ?? null ;
23+ try {
24+ $ body = $ this ->httpClient ->get ('https://api.github.com/repos/tempestphp/tempest-framework ' )->body ;
25+ $ stargazers = json_decode ($ body )->stargazers_count ?? null ;
2426
25- return $ stargazers > 999
26- ? (round ($ stargazers / 1000 , 1 ) . 'K ' )
27- : $ stargazers ;
27+ return $ stargazers > 999
28+ ? (round ($ stargazers / 1000 , 1 ) . 'K ' )
29+ : $ stargazers ;
30+ } catch (Throwable $ e ) {
31+ ll ($ e );
32+ return null ;
33+ }
2834 },
2935 expiresAt: new DateTimeImmutable ('+12 hours ' ),
3036 );
You can’t perform that action at this time.
0 commit comments