예제 #1
0
 /**
  * Reads the environment file either by parsing it directly or from a cached file
  */
 public function read()
 {
     if ($this->cache->isEnabled()) {
         if ($this->cache->hasCache()) {
             $this->cache->loadCache();
         } else {
             $superGlobalEnvBackup = $_ENV;
             $this->parseEnvironmentVariables();
             $writtenEnvVars = array_diff_assoc($_ENV, $superGlobalEnvBackup);
             $this->cache->storeCache($this->getCachedCode($writtenEnvVars));
         }
     } else {
         $this->parseEnvironmentVariables();
     }
 }
예제 #2
0
 /**
  * @test
  */
 public function loadRequiresCacheFile()
 {
     $cacheDir = __DIR__ . '/Fixtures/cache';
     $cache = new Cache($cacheDir, __DIR__ . '/Fixtures/env');
     $cache->storeCache('<?php' . PHP_EOL . '$GLOBALS[\'BLA\'] = \'blupp\';');
     $cache->loadCache();
     $this->assertSame('blupp', $GLOBALS['BLA']);
 }