Skip to content
Snippets Groups Projects

Resolve "Remove all use of GLOBALS"

Merged Stein Magne Bjorklund requested to merge 13-remove-all-use-of-globals into master
1 file
+ 10
9
Compare changes
  • Side-by-side
  • Inline
+ 10
9
@@ -3,6 +3,8 @@
namespace uib\ub\loadspeakr;
use UnexpectedValueException;
final class Endpoint
{
private string $sparqlUrl;
@@ -47,10 +49,14 @@ final class Endpoint
$this->updateCache($result['status'], $cacheFile, $aux, $conf);
}
if (!$aux) {
return $aux;
}
return $this->result($q, $aux);
}
private function result($q, $aux)
private function result(string $q, string $aux)
{
if (false !== stripos($q, "select")) {
return json_decode($aux, true);
@@ -76,22 +82,17 @@ final class Endpoint
return !empty($conf['cache']['global']) && is_int($conf['cache']['global']) && $conf['cache']['global'] > 0;
}
private function updateCache($http_status, $cacheFile, $aux, $conf)
private function updateCache($http_status, $cacheFile, $aux, $conf): void
{
$result = false;
if ($this->caching($conf) && $http_status == 200) {
if ($http_status === 200 && $this->caching($conf)) {
$result = file_put_contents($cacheFile, ($aux), LOCK_EX);
if (!$result) {
throw new \UnexpectedValueException(
throw new UnexpectedValueException(
'Unable to update cache: ' . $cacheFile
);
}
}
return $result;
}
private function curl(string $request, $accept, array $conf): array
Loading