summaryrefslogtreecommitdiffstats
path: root/lib/Providers/Time/ConvertUnixTimeDotComTimeProvider.php
blob: 4939f0d40614d8c1a121e565b871ca6de2dad261 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php

namespace RobThree\Auth\Providers\Time;

class ConvertUnixTimeDotComTimeProvider implements ITimeProvider
{
    public function getTime() {
        $json = @json_decode(
            @file_get_contents('http://www.convert-unix-time.com/api?timestamp=now')
        );
        if ($json === null || !is_int($json->timestamp))
            throw new \TimeException('Unable to retrieve time from convert-unix-time.com');
        return $json->timestamp;
    }
}