diff --git a/src/Cache.php b/src/Cache.php index 2fe21df5..5a15930b 100644 --- a/src/Cache.php +++ b/src/Cache.php @@ -57,12 +57,24 @@ public static function isCached() * Set cache. * * @param mixed $contents + * + * @return int */ public static function put($contents) { return file_put_contents(self::getFilename(), json_encode($contents)); } + /** + * Set cache filename. + * + * @param string $filename + */ + public static function setFilename($filename) + { + self::$filename = $filename; + } + /** * Return cache filename. * diff --git a/src/Command/LintCommand.php b/src/Command/LintCommand.php index 2b0d2850..43aa3cfa 100644 --- a/src/Command/LintCommand.php +++ b/src/Command/LintCommand.php @@ -94,6 +94,12 @@ protected function configure() null, InputOption::VALUE_NONE, 'Ignore cached data.' + ) + ->addOption( + 'cache', + null, + InputOption::VALUE_REQUIRED, + 'Path to the cache file.' ); } @@ -146,6 +152,10 @@ protected function execute(InputInterface $input, OutputInterface $output) $linter = new Linter($options['path'], $options['exclude'], $options['extensions']); $linter->setProcessLimit($options['jobs']); + if ($input->getOption('cache') !== null) { + Cache::setFilename($input->getOption('cache')); + } + if (!$input->getOption('no-cache') && Cache::isCached()) { $output->writeln('Using cache.'); $linter->setCache(Cache::get());