Completed
Push — master ( a505a0...5d1dca )
by Fèvre
20s
created

UsersTwoFactorAuthTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 41
Duplicated Lines 34.15 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
c 0
b 0
f 0
lcom 1
cbo 2
dl 14
loc 41
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A _initializeSchema() 0 9 1
A initialize() 14 14 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
namespace App\Model\Table;
3
4
use Cake\Database\Schema\Table as Schema;
5
use Cake\ORM\Table;
6
7
class UsersTwoFactorAuthTable extends Table
8
{
9
    /**
10
     * Initialize schema method
11
     *
12
     * @param \Cake\Database\Schema\Table $schema The schema of the Table.
13
     *
14
     * @return \Cake\Database\Schema\Table
15
     */
16
    protected function _initializeSchema(Schema $schema)
17
    {
18
        $schema->columnType('secret', 'encryptedsecurity');
19
        $schema->columnType('username', 'encryptedsecurity');
20
        $schema->columnType('session', 'encryptedsecurity');
21
        $schema->columnType('recovery_code', 'encryptedsecurity');
22
23
        return $schema;
24
    }
25
26
    /**
27
     * Initialize method
28
     *
29
     * @param array $config The configuration for the Table.
30
     *
31
     * @return void
32
     */
33 View Code Duplication
    public function initialize(array $config)
0 ignored issues
show
Duplication introduced by
This method 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...
34
    {
35
        parent::initialize($config);
36
37
        $this->table('users_two_factor_auth');
38
        $this->displayField('id');
39
        $this->primaryKey('id');
40
41
        $this->addBehavior('Timestamp');
42
43
        $this->belongsTo('Users', [
44
            'foreignKey' => 'user_id'
45
        ]);
46
    }
47
}
48