/** * Constructor. * * @access protected */ protected function __construct() { // Set current time static::$now = time(); // Cache key allows us to invalidate all cache on configuration changes. static::$key = (Config::get('system.cache.prefix') ? Config::get('system.cache.prefix') : 'fansoro') . '-' . md5(ROOT_DIR . Fansoro::VERSION); // Get Cache Driver static::$driver = static::getCacheDriver(); // Set the cache namespace to our unique key static::$driver->setNamespace(static::$key); }
/** * @param null|bool|string $time * @return DateTime */ public static function now($time = null) { if ($time === false) { // reset $now. static::$now = null; } elseif ($time === true) { // regenerate now. static::$now = new static(); } elseif (is_string($time)) { // use new now with $time string. static::$now = new static($time); } elseif (!static::$now) { // first time. create new. static::$now = new static(); } return static::$now; }
public static function setTestNow(DateTime $dt = null) { static::$now = $dt; }
protected static function populateKey() { static::$now = new \DateTime("@1443816900"); static::$key = [(new Cell("region"))->setValue("South Atlantic"), (new Cell("state"))->setValue("South Carolina"), (new Cell("time"))->setTimestampValue(static::$now->getTimestamp())]; }