Completed
Push — master ( 41af6a...be871c )
by Fèvre
11s
created

PollsTable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
B initialize() 0 27 1
A validationDefault() 0 8 1
1
<?php
2
namespace App\Model\Table;
3
4
use Cake\ORM\Table;
5
use Cake\Validation\Validator;
6
7
class PollsTable extends Table
8
{
9
10
    /**
11
     * Initialize method
12
     *
13
     * @param array $config The configuration for the Table.
14
     *
15
     * @return void
16
     */
17
    public function initialize(array $config)
18
    {
19
        parent::initialize($config);
20
21
        $this->table('polls');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::table() has been deprecated with message: 3.4.0 Use setTable()/getTable() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
22
        $this->displayField('name');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::displayField() has been deprecated with message: 3.4.0 Use setDisplayField()/getDisplayField() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
23
        $this->primaryKey('id');
0 ignored issues
show
Deprecated Code introduced by
The method Cake\ORM\Table::primaryKey() has been deprecated with message: 3.4.0 Use setPrimaryKey()/getPrimaryKey() instead.

This method has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the method will be removed from the class and what other method or class to use instead.

Loading history...
24
25
        $this->addBehavior('Timestamp');
26
27
        $this->belongsTo('Users', [
28
            'foreignKey' => 'user_id'
29
        ]);
30
        $this->belongsTo('BlogArticles', [
31
            'foreignKey' => 'article_id'
32
        ]);
33
        $this->hasMany('PollsAnswers', [
34
            'foreignKey' => 'poll_id',
35
            'dependent' => true,
36
            'cascadeCallbacks' => true
37
        ]);
38
        $this->hasMany('PollsUsers', [
39
            'foreignKey' => 'poll_id',
40
            'dependent' => true,
41
            'cascadeCallbacks' => true
42
        ]);
43
    }
44
45
    /**
46
     * Default validation rules.
47
     *
48
     * @param \Cake\Validation\Validator $validator Validator instance.
49
     *
50
     * @return \Cake\Validation\Validator
51
     */
52
    public function validationDefault(Validator $validator)
53
    {
54
        $validator
55
            ->requirePresence('name', 'create')
56
            ->notEmpty('name');
57
58
        return $validator;
59
    }
60
}
61