@@ -90,7 +90,7 @@ public function getRules(string $url = self::PSL_URL, $ttl = null): Rules
90
90
return new Rules ($ data );
91
91
}
92
92
93
- throw new CouldNotLoadRules ('The public suffix list cache is corrupted: ' . json_last_error_msg (), json_last_error ());
93
+ throw new CouldNotLoadRules (sprintf ( 'The public suffix list cache is corrupted: %s ' , json_last_error_msg () ), json_last_error ());
94
94
}
95
95
96
96
/**
@@ -110,12 +110,9 @@ public function refreshRules(string $url = self::PSL_URL, $ttl = null): bool
110
110
static $ converter ;
111
111
112
112
$ converter = $ converter ?? new Converter ();
113
+ $ data = json_encode ($ converter ->convert ($ this ->http ->getContent ($ url )));
113
114
114
- return $ this ->cache ->set (
115
- $ this ->getCacheKey ('PSL ' , $ url ),
116
- json_encode ($ converter ->convert ($ this ->http ->getContent ($ url ))),
117
- $ this ->filterTtl ($ ttl ) ?? $ this ->ttl
118
- );
115
+ return $ this ->cache ->set ($ this ->getCacheKey ('PSL ' , $ url ), $ data , $ this ->filterTtl ($ ttl ) ?? $ this ->ttl );
119
116
}
120
117
121
118
/**
@@ -139,11 +136,11 @@ public function getTLDs(string $url = self::RZD_URL, $ttl = null): TopLevelDomai
139
136
140
137
$ data = json_decode ($ data ?? $ this ->cache ->get ($ key ), true );
141
138
if (JSON_ERROR_NONE !== json_last_error ()) {
142
- throw new CouldNotLoadTLDs ('The root zone database cache is corrupted: ' . json_last_error_msg (), json_last_error ());
139
+ throw new CouldNotLoadTLDs (sprintf ( 'The root zone database cache is corrupted: %s ' , json_last_error_msg () ), json_last_error ());
143
140
}
144
141
145
142
if (!isset ($ data ['records ' ], $ data ['version ' ], $ data ['modifiedDate ' ])) {
146
- throw new CouldNotLoadTLDs (sprintf ( 'The root zone database cache content is corrupted ' ) );
143
+ throw new CouldNotLoadTLDs ('The root zone database cache content is corrupted ' );
147
144
}
148
145
149
146
return new TopLevelDomains (
@@ -170,12 +167,9 @@ public function refreshTLDs(string $url = self::RZD_URL, $ttl = null): bool
170
167
static $ converter ;
171
168
172
169
$ converter = $ converter ?? new TLDConverter ();
170
+ $ data = json_encode ($ converter ->convert ($ this ->http ->getContent ($ url )));
173
171
174
- return $ this ->cache ->set (
175
- $ this ->getCacheKey ('RZD ' , $ url ),
176
- json_encode ($ converter ->convert ($ this ->http ->getContent ($ url ))),
177
- $ this ->filterTtl ($ ttl ) ?? $ this ->ttl
178
- );
172
+ return $ this ->cache ->set ($ this ->getCacheKey ('RZD ' , $ url ), $ data , $ this ->filterTtl ($ ttl ) ?? $ this ->ttl );
179
173
}
180
174
181
175
/**
0 commit comments