ThreemaGateway_Installer_TfaPendingConfirmMsgs   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 36
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 16 16 1
A destroy() 5 5 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * Adds/Deletes the pending message confirm table.
4
 *
5
 * @package ThreemaGateway
6
 * @author rugk
7
 * @copyright Copyright (c) 2015-2016 rugk
8
 * @license MIT
9
 */
10
11
/**
12
 * Methods for creating or deleting the message confirm table.
13
 */
14 View Code Duplication
class ThreemaGateway_Installer_TfaPendingConfirmMsgs
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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