Completed
Push — master ( 6f92e6...cbba0d )
by Fèvre
9s
created

PollsUsersTable   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 68.57 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 1
lcom 1
cbo 1
dl 24
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B initialize() 24 24 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\ORM\Table;
5
6
/**
7
 * PollsUsers Model
8
 *
9
 * @property \Cake\ORM\Association\BelongsTo $Polls
10
 * @property \Cake\ORM\Association\BelongsTo $Users
11
 * @property \Cake\ORM\Association\BelongsTo $PollsAnswers
12
 */
13
class PollsUsersTable extends Table
14
{
15
16
    /**
17
     * Initialize method
18
     *
19
     * @param array $config The configuration for the Table.
20
     *
21
     * @return void
22
     */
23 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...
24
    {
25
        parent::initialize($config);
26
27
        $this->table('polls_users');
28
        $this->displayField('id');
29
        $this->primaryKey('id');
30
31
        $this->addBehavior('Timestamp');
32
        $this->addBehavior('CounterCache', [
33
            'Polls' => ['user_count'],
34
            'PollsAnswers' => ['user_count']
35
        ]);
36
37
        $this->belongsTo('Polls', [
38
            'foreignKey' => 'poll_id'
39
        ]);
40
        $this->belongsTo('Users', [
41
            'foreignKey' => 'user_id'
42
        ]);
43
        $this->belongsTo('PollsAnswers', [
44
            'foreignKey' => 'answer_id'
45
        ]);
46
    }
47
}
48