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

PollsUsersTable::initialize()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 24
Code Lines 15

Duplication

Lines 24
Ratio 100 %

Importance

Changes 0
Metric Value
dl 24
loc 24
rs 8.9713
c 0
b 0
f 0
cc 1
eloc 15
nc 1
nop 1
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