for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace BrainExe\Core\Traits;
/**
* @api
*/
trait FileCacheTrait
{
* @param string $name
* @return mixed
protected function includeFile(string $name)
$filename = $this->getCacheFileName($name);
if (!is_file($filename)) {
return null;
}
return include $filename;
* @param string $content
protected function dumpCacheFile(string $name, string $content)
$fileName = $this->getCacheFileName($name);
file_put_contents($fileName, "<?php \n//@codingStandardsIgnoreFile" . PHP_EOL . $content);
* @param mixed $variable
protected function dumpVariableToCache(string $name, $variable)
$this->dumpCacheFile($name, 'return ' . var_export($variable, true) . ';');
* @return string
private function getCacheFileName($name)
return ROOT . 'cache/' . basename($name, '.php') . '.php';