Code Duplication    Length = 61-61 lines in 2 locations

src/Package/MySqlPassportMigration.php 1 location

@@ 28-88 (lines=61) @@
25
/**
26
 * @package Limoncello\Passport
27
 */
28
class MySqlPassportMigration implements MigrationInterface
29
{
30
    use DatabaseSchemaMigrationTrait;
31
32
    /**
33
     * @var ContainerInterface
34
     */
35
    private $container;
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function init(ContainerInterface $container): MigrationInterface
41
    {
42
        $this->container = $container;
43
44
        return $this;
45
    }
46
47
    /**
48
     * @return void
49
     */
50
    public function migrate(): void
51
    {
52
        $this->createDatabaseSchema($this->getConnection(), $this->getDatabaseSchema());
53
    }
54
55
    /**
56
     * @return void
57
     */
58
    public function rollback(): void
59
    {
60
        $this->removeDatabaseSchema($this->getConnection(), $this->getDatabaseSchema());
61
    }
62
63
    /**
64
     * @return ContainerInterface
65
     */
66
    protected function getContainer(): ContainerInterface
67
    {
68
        assert($this->container !== null);
69
70
        return $this->container;
71
    }
72
73
    /**
74
     * @return Connection
75
     */
76
    protected function getConnection(): Connection
77
    {
78
        return $this->getContainer()->get(Connection::class);
79
    }
80
81
    /**
82
     * @return DatabaseSchemaInterface
83
     */
84
    protected function getDatabaseSchema(): DatabaseSchemaInterface
85
    {
86
        return $this->getContainer()->get(DatabaseSchemaInterface::class);
87
    }
88
}
89

src/Package/PassportMigration.php 1 location

@@ 28-88 (lines=61) @@
25
/**
26
 * @package Limoncello\Passport
27
 */
28
class PassportMigration implements MigrationInterface
29
{
30
    use DatabaseSchemaMigrationTrait;
31
32
    /**
33
     * @var ContainerInterface
34
     */
35
    private $container;
36
37
    /**
38
     * @inheritdoc
39
     */
40
    public function init(ContainerInterface $container): MigrationInterface
41
    {
42
        $this->container = $container;
43
44
        return $this;
45
    }
46
47
    /**
48
     * @return void
49
     */
50
    public function migrate(): void
51
    {
52
        $this->createDatabaseSchema($this->getConnection(), $this->getDatabaseSchema());
53
    }
54
55
    /**
56
     * @return void
57
     */
58
    public function rollback(): void
59
    {
60
        $this->removeDatabaseSchema($this->getConnection(), $this->getDatabaseSchema());
61
    }
62
63
    /**
64
     * @return ContainerInterface
65
     */
66
    protected function getContainer(): ContainerInterface
67
    {
68
        assert($this->container !== null);
69
70
        return $this->container;
71
    }
72
73
    /**
74
     * @return Connection
75
     */
76
    protected function getConnection(): Connection
77
    {
78
        return $this->getContainer()->get(Connection::class);
79
    }
80
81
    /**
82
     * @return DatabaseSchemaInterface
83
     */
84
    protected function getDatabaseSchema(): DatabaseSchemaInterface
85
    {
86
        return $this->getContainer()->get(DatabaseSchemaInterface::class);
87
    }
88
}
89