Code Duplication    Length = 28-36 lines in 3 locations

src/library/ThreemaGateway/Installer/ActionThrottle.php 1 location

@@ 14-44 (lines=31) @@
11
/**
12
 * Methods for creating or deleting the action throttle table.
13
 */
14
class ThreemaGateway_Installer_ActionThrottle
15
{
16
    /**
17
     * @var string database table name
18
     */
19
    const DB_TABLE = 'xf_threemagw_action_throttle';
20
21
    /**
22
     * Create a new table in the database.
23
     */
24
    public function create()
25
    {
26
        $db = XenForo_Application::get('db');
27
        $db->query('CREATE TABLE `' . self::DB_TABLE . '`
28
            (`action_id` INT(11) UNSIGNED NOT NULL AUTO_INCREMENT,
29
            `user_id` INT(10) UNSIGNED NOT NULL,
30
            `action_date` INT(10) UNSIGNED NOT NULL,
31
            `action_type` VARBINARY(25) NOT NULL,
32
            PRIMARY KEY(`action_id`)
33
            ) COMMENT=\'Temporarily logs Threema Gateway actions of users in order to limit them.\'');
34
    }
35
36
    /**
37
     * Deletes the table.
38
     */
39
    public function destroy()
40
    {
41
        $db = XenForo_Application::get('db');
42
        $db->query('DROP TABLE `' . self::DB_TABLE . '`');
43
    }
44
}
45

src/library/ThreemaGateway/Installer/Keystore.php 1 location

@@ 14-41 (lines=28) @@
11
/**
12
 * Methods for creating or deleting the keystore table.
13
 */
14
class ThreemaGateway_Installer_Keystore
15
{
16
    /**
17
     * @var string database table name
18
     */
19
    const DB_TABLE = 'xf_threemagw_keystore';
20
21
    /**
22
     * Create a new keystore (table) in the database.
23
     */
24
    public function create()
25
    {
26
        $db = XenForo_Application::get('db');
27
        $db->query('CREATE TABLE `' . self::DB_TABLE . '`
28
            (`threema_id` CHAR(8) NOT NULL PRIMARY KEY,
29
            `public_key` CHAR(64) NOT NULL)
30
            ');
31
    }
32
33
    /**
34
     * Deletes the keystore (table).
35
     */
36
    public function destroy()
37
    {
38
        $db = XenForo_Application::get('db');
39
        $db->query('DROP TABLE `' . self::DB_TABLE . '`');
40
    }
41
}
42

src/library/ThreemaGateway/Installer/TfaPendingConfirmMsgs.php 1 location

@@ 14-49 (lines=36) @@
11
/**
12
 * Methods for creating or deleting the message confirm table.
13
 */
14
class ThreemaGateway_Installer_TfaPendingConfirmMsgs
15
{
16
    /**
17
     * @var string database table name
18
     */
19
    const DB_TABLE = 'xf_threemagw_tfa_pending_msgs_confirm';
20
21
    /**
22
     * Create a new table in the database.
23
     */
24
    public function create()
25
    {
26
        $db = XenForo_Application::get('db');
27
        $db->query('CREATE TABLE `' . self::DB_TABLE . '`
28
            (`request_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
29
            `threema_id` CHAR(8) NOT NULL,
30
            `provider_id` VARBINARY(25) NOT NULL,
31
            `pending_type` TINYINT(3) UNSIGNED NOT NULL,
32
            `user_id` INT(10) UNSIGNED NOT NULL,
33
            `session_id` VARBINARY(32) NOT NULL,
34
            `extra_data` BLOB COMMENT \'any extra data, which may be used for verifying whether a request is valid\',
35
            `expiry_date` INT(10) UNSIGNED NOT NULL,
36
            PRIMARY KEY(`request_id`),
37
            INDEX(`expiry_date`)
38
            ) COMMENT=\'Stores pending 2FA requests for confirmation messages for receiver/callback.\'');
39
    }
40
41
    /**
42
     * Deletes the table.
43
     */
44
    public function destroy()
45
    {
46
        $db = XenForo_Application::get('db');
47
        $db->query('DROP TABLE `' . self::DB_TABLE . '`');
48
    }
49
}
50