for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Cerbero\SqlDumper\Dumpers;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Config;
/**
* Abstract implementation of a file dumper.
*
*/
abstract class FileDumper implements DumperInterface
{
* The path of the file to generate.
* @var string
protected $path;
* The file extension.
protected $extension;
* The file content.
protected $content = '';
* Instantiate the class.
* @param string $path
public function __construct(string $path = null)
$this->path = $path ?: $this->getDefaultPath();
}
* Retrieve the default file path
* @return string
protected function getDefaultPath(): string
if ($path = Config::get('sql_dumper.' . static::class . '.path')) {
return $path;
return App::storagePath() . '/sql_dump_' . time() . '.' . $this->getExtension();
* Retrieve the file extension
protected function getExtension(): string
return (string) $this->extension;
* Retrieve the file path
public function getPath(): string
return $this->path;
* Retrieve the file content
public function getContent(): string
return $this->content;
* Dump queries information
* @return mixed
public function dump()
file_put_contents($this->path, $this->content);
$this->content = '';