1
0
mirror of https://github.com/erusev/parsedown.git synced 2023-08-10 21:13:06 +03:00

PHP 5.5 compat

This commit is contained in:
Aidan Woods 2019-02-03 01:03:45 +00:00
parent 9bf91d7183
commit 93650fb9b5
No known key found for this signature in database
GPG Key ID: 9A6A8EFAA512BBB9

View File

@ -17,8 +17,8 @@ use PHPUnit\Framework\TestCase;
class CommonMarkTestStrict extends TestCase class CommonMarkTestStrict extends TestCase
{ {
const SPEC_URL = 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt'; const SPEC_URL = 'https://raw.githubusercontent.com/jgm/CommonMark/master/spec.txt';
const SPEC_LOCAL_CACHE = __DIR__ .'/spec_cache.txt'; const SPEC_LOCAL_CACHE = 'spec_cache.txt';
const SPEC_CACHE_SECONDS = 5 * 60; const SPEC_CACHE_SECONDS = 300;
protected $parsedown; protected $parsedown;
@ -45,14 +45,16 @@ class CommonMarkTestStrict extends TestCase
public static function getSpec() public static function getSpec()
{ {
$specPath = __DIR__ .'/'.self::SPEC_LOCAL_CACHE;
if ( if (
\is_file(self::SPEC_LOCAL_CACHE) \is_file($specPath)
&& \time() - \filemtime(self::SPEC_LOCAL_CACHE) < self::SPEC_CACHE_SECONDS && \time() - \filemtime($specPath) < self::SPEC_CACHE_SECONDS
) { ) {
$spec = \file_get_contents(self::SPEC_LOCAL_CACHE); $spec = \file_get_contents($specPath);
} else { } else {
$spec = \file_get_contents(self::SPEC_URL); $spec = \file_get_contents(self::SPEC_URL);
\file_put_contents(self::SPEC_LOCAL_CACHE, $spec); \file_put_contents($specPath, $spec);
} }
return $spec; return $spec;