AppMigration.php
2 years ago
AppMigrationTemplate.php
2 years ago
Cli.php
2 weeks ago
DbMigration.php
6 months ago
DbMigrationTemplate.php
2 years ago
Logger.php
2 years ago
Migrator.php
1 year ago
MigratorException.php
2 years ago
Repository.php
2 years ago
Runner.php
2 years ago
Store.php
6 months ago
index.php
3 years ago
MigratorException.php
54 lines
| 1 | <?php declare(strict_types = 1); |
| 2 | |
| 3 | namespace MailPoet\Migrator; |
| 4 | |
| 5 | if (!defined('ABSPATH')) exit; |
| 6 | |
| 7 | |
| 8 | use MailPoet\InvalidStateException; |
| 9 | use Throwable; |
| 10 | |
| 11 | class MigratorException extends InvalidStateException { |
| 12 | public static function templateFileReadFailed(string $path): self { |
| 13 | return self::create()->withMessage( |
| 14 | sprintf('Could not read migration template file "%s".', $path) |
| 15 | ); |
| 16 | } |
| 17 | |
| 18 | public static function invalidMigrationLevel(string $level): self { |
| 19 | return self::create()->withMessage( |
| 20 | sprintf('Migration level "%s" is not supported! Use "app" or "db".', $level) |
| 21 | ); |
| 22 | } |
| 23 | |
| 24 | public static function duplicateMigrationNames(array $names): self { |
| 25 | return self::create()->withMessage( |
| 26 | sprintf('Duplicate migration names are not allowed. Duplicate names found: "%s".', join(', ', $names)) |
| 27 | ); |
| 28 | } |
| 29 | |
| 30 | public static function migrationFileWriteFailed(string $path): self { |
| 31 | return self::create()->withMessage( |
| 32 | sprintf('Could not write migration file "%s".', $path) |
| 33 | ); |
| 34 | } |
| 35 | |
| 36 | public static function migrationClassNotFound(string $className): self { |
| 37 | return self::create()->withMessage( |
| 38 | sprintf('Migration class "%s" not found.', $className) |
| 39 | ); |
| 40 | } |
| 41 | |
| 42 | public static function migrationClassIsNotASubclassOf(string $className, string $parentClassName): self { |
| 43 | return self::create()->withMessage( |
| 44 | sprintf('Migration class "%1$s" is not a subclass of "%2$s".', $className, $parentClassName) |
| 45 | ); |
| 46 | } |
| 47 | |
| 48 | public static function migrationFailed(string $className, Throwable $previous): self { |
| 49 | return self::create($previous)->withMessage( |
| 50 | sprintf('Migration "%1$s" failed. Details: %2$s', $className, $previous->getMessage()) |
| 51 | ); |
| 52 | } |
| 53 | } |
| 54 |