🎨 fix the majority of code sniffs

This commit is contained in:
William Hall
2021-02-08 17:28:05 +00:00
parent 14e90c3faa
commit 2aa6f46e20
18 changed files with 194 additions and 140 deletions
+8 -4
View File
@@ -2,6 +2,8 @@
namespace RobThree\Auth\Providers\Time;
use DateTime;
/**
* Takes the time from any webserver by doing a HEAD request on the specified URL and extracting the 'Date:' header
*/
@@ -11,7 +13,7 @@ class HttpTimeProvider implements ITimeProvider
public $options;
public $expectedtimeformat;
function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
public function __construct($url = 'https://google.com', $expectedtimeformat = 'D, d M Y H:i:s O+', array $options = null)
{
$this->url = $url;
$this->expectedtimeformat = $expectedtimeformat;
@@ -34,7 +36,8 @@ class HttpTimeProvider implements ITimeProvider
}
}
public function getTime() {
public function getTime()
{
try {
$context = stream_context_create($this->options);
$fd = fopen($this->url, 'rb', false, $context);
@@ -42,8 +45,9 @@ class HttpTimeProvider implements ITimeProvider
fclose($fd);
foreach ($headers['wrapper_data'] as $h) {
if (strcasecmp(substr($h, 0, 5), 'Date:') === 0)
return \DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h,5)))->getTimestamp();
if (strcasecmp(substr($h, 0, 5), 'Date:') === 0) {
return DateTime::createFromFormat($this->expectedtimeformat, trim(substr($h, 5)))->getTimestamp();
}
}
throw new \Exception('Invalid or no "Date:" header found');
} catch (\Exception $ex) {