comparison vendor/psy/psysh/src/VersionUpdater/IntervalChecker.php @ 4:a9cd425dd02b

Update, including to Drupal core 8.6.10
author Chris Cannam
date Thu, 28 Feb 2019 13:11:55 +0000
parents c75dbcec494b
children
comparison
equal deleted inserted replaced
3:307d7a7fd348 4:a9cd425dd02b
8 * For the full copyright and license information, please view the LICENSE 8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code. 9 * file that was distributed with this source code.
10 */ 10 */
11 11
12 namespace Psy\VersionUpdater; 12 namespace Psy\VersionUpdater;
13
14 use Psy\Shell;
15 13
16 class IntervalChecker extends GitHubChecker 14 class IntervalChecker extends GitHubChecker
17 { 15 {
18 private $cacheFile; 16 private $cacheFile;
19 private $interval; 17 private $interval;
25 } 23 }
26 24
27 public function fetchLatestRelease() 25 public function fetchLatestRelease()
28 { 26 {
29 // Read the cached file 27 // Read the cached file
30 $cached = json_decode(@file_get_contents($this->cacheFile, false)); 28 $cached = \json_decode(@\file_get_contents($this->cacheFile, false));
31 if ($cached && isset($cached->last_check) && isset($cached->release)) { 29 if ($cached && isset($cached->last_check) && isset($cached->release)) {
32 $now = new \DateTime(); 30 $now = new \DateTime();
33 $lastCheck = new \DateTime($cached->last_check); 31 $lastCheck = new \DateTime($cached->last_check);
34 if ($lastCheck >= $now->sub($this->getDateInterval())) { 32 if ($lastCheck >= $now->sub($this->getDateInterval())) {
35 return $cached->release; 33 return $cached->release;
58 } 56 }
59 57
60 private function updateCache($release) 58 private function updateCache($release)
61 { 59 {
62 $data = [ 60 $data = [
63 'last_check' => date(DATE_ATOM), 61 'last_check' => \date(DATE_ATOM),
64 'release' => $release, 62 'release' => $release,
65 ]; 63 ];
66 64
67 file_put_contents($this->cacheFile, json_encode($data)); 65 \file_put_contents($this->cacheFile, \json_encode($data));
68 } 66 }
69 } 67 }