diff --git a/src/Service/DumpFilenameParser.php b/src/Service/DumpFilenameParser.php new file mode 100644 index 0000000..545b5cc --- /dev/null +++ b/src/Service/DumpFilenameParser.php @@ -0,0 +1,37 @@ +format('Y-m-d_H-i-s') . '.sql.gz'; + } + + public function parse(string $filename): ?\DateTimeImmutable + { + if (preg_match(self::PATTERN, $filename, $matches) !== 1) { + return null; + } + + $dateTime = \DateTimeImmutable::createFromFormat( + 'Y-m-d_H-i-s', + $matches[1] . '_' . $matches[2] + ); + + return $dateTime ?: null; + } + + public function isValid(string $filename): bool + { + return $this->parse($filename) !== null; + } +} diff --git a/src/Service/MySqlVariant.php b/src/Service/MySqlVariant.php new file mode 100644 index 0000000..1f609da --- /dev/null +++ b/src/Service/MySqlVariant.php @@ -0,0 +1,17 @@ +