/** * @param ConfigInterface $config * @param bool $isDryRun * * @return CacheManagerInterface */ private function createCacheManager(ConfigInterface $config, $isDryRun) { if ($config->usingCache() && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer())) { return new FileCacheManager(new FileHandler($config->getCacheFile()), new Signature(PHP_VERSION, ToolInfo::getVersion(), $config->usingLinter(), $config->getRules()), $isDryRun); } return new NullCacheManager(); }
private function saveToFile() { if (!$this->isCacheAvailable()) { return; } $data = serialize(array('version' => ToolInfo::getVersion(), 'rules' => $this->rules, 'hashes' => $this->newHashes)); if (false === @file_put_contents($this->cacheFile, $data, LOCK_EX)) { throw new IOException(sprintf('Failed to write file "%s".', $this->cacheFile), 0, null, $this->cacheFile); } }
/** * @return CacheManagerInterface */ public function getCacheManager() { if (null === $this->cacheManager) { if ($this->getUsingCache() && (ToolInfo::isInstalledAsPhar() || ToolInfo::isInstalledByComposer())) { $this->cacheManager = new FileCacheManager(new FileHandler($this->getCacheFile()), new Signature(PHP_VERSION, ToolInfo::getVersion(), $this->getRules()), $this->isDryRun()); } else { $this->cacheManager = new NullCacheManager(); } } return $this->cacheManager; }
public function testGetVersion() { $this->assertInternalType('string', ToolInfo::getVersion()); }