Code Duplication    Length = 50-52 lines in 2 locations

database/migration/Charcoal/Email/Migration20200827131900.php 1 location

@@ 13-62 (lines=50) @@
10
/**
11
 * Migration 2020-08-27 13:19:00
12
 */
13
class Migration20200827131900 extends AbstractMigration
14
{
15
    use ModelFactoryTrait;
16
17
    /**
18
     * @return string
19
     */
20
    public function description(): string
21
    {
22
        return 'Email queue item // add expiry date';
23
    }
24
25
    /**
26
     * Inject dependencies from a DI Container.
27
     *
28
     * @param Container $container A Pimple DI service container.
29
     * @return void
30
     */
31
    protected function setDependencies(Container $container): void
32
    {
33
        parent::setDependencies($container);
34
35
        $this->setModelFactory($container['model/factory']);
36
    }
37
38
    /**
39
     * Apply migration
40
     *
41
     * @return void
42
     */
43
    public function up(): void
44
    {
45
        try {
46
            /** @var EmailQueueItem $proto */
47
            $proto = $this->modelFactory()->create(EmailQueueItem::class);
48
            $table = $proto->source()->table();
49
50
            $this->addFeedback(
51
                "Updating <white>${table} Table</white>."
52
            );
53
54
            $this->createOrAlter($proto);
55
        } catch (PDOException $exception) {
56
            $this->addError($exception->getMessage());
57
            $this->setStatus(self::FAILED_STATUS);
58
        }
59
60
        $this->setStatus(self::PROCESSED_STATUS);
61
    }
62
}
63

database/migration/Charcoal/Email/Migration20200915025000.php 1 location

@@ 13-64 (lines=52) @@
10
/**
11
 * Migration 2020-09-15 02:25:00
12
 */
13
final class Migration20200915025000 extends AbstractMigration
14
{
15
    use ModelFactoryTrait;
16
17
    /**
18
     * Short description of what the patch will do.
19
     *
20
     * @return string
21
     */
22
    public function description(): string
23
    {
24
        return 'Email queue item // add status property';
25
    }
26
27
    /**
28
     * Inject dependencies from a DI Container.
29
     *
30
     * @param Container $container A Pimple DI service container.
31
     * @return void
32
     */
33
    protected function setDependencies(Container $container): void
34
    {
35
        parent::setDependencies($container);
36
37
        $this->setModelFactory($container['model/factory']);
38
    }
39
40
    /**
41
     * Apply migration
42
     *
43
     * @return void
44
     */
45
    public function up(): void
46
    {
47
        try {
48
            /** @var EmailQueueItem $proto */
49
            $proto = $this->modelFactory()->create(EmailQueueItem::class);
50
            $table = $proto->source()->table();
51
52
            $this->addFeedback(
53
                "Updating <white>${table} Table</white>."
54
            );
55
56
            $this->createOrAlter($proto);
57
        } catch (PDOException $exception) {
58
            $this->addError($exception->getMessage());
59
            $this->setStatus(self::FAILED_STATUS);
60
        }
61
62
        $this->setStatus(self::PROCESSED_STATUS);
63
    }
64
}
65