Passed
Branch master (44bfae)
by giu
03:41
created

UseroptionsTable::initialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 13
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 8
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 13
ccs 0
cts 8
cp 0
crap 2
rs 10
1
<?php
2
namespace App\Model\Table;
3
4
use Cake\ORM\Query;
5
use Cake\ORM\RulesChecker;
6
use Cake\ORM\Table;
7
use Cake\Validation\Validator;
8
9
/**
10
 * Useroptions Model
11
 *
12
 * @property \Cake\ORM\Association\BelongsTo $Users
13
 *
14
 * @method \App\Model\Entity\Useroption get($primaryKey, $options = [])
15
 * @method \App\Model\Entity\Useroption newEntity($data = null, array $options = [])
16
 * @method \App\Model\Entity\Useroption[] newEntities(array $data, array $options = [])
17
 * @method \App\Model\Entity\Useroption|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
18
 * @method \App\Model\Entity\Useroption patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19
 * @method \App\Model\Entity\Useroption[] patchEntities($entities, array $data, array $options = [])
20
 * @method \App\Model\Entity\Useroption findOrCreate($search, callable $callback = null, $options = [])
21
 *
22
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
23
 */
24
class UseroptionsTable extends Table
25
{
26
27
    /**
28
     * Initialize method
29
     *
30
     * @param array $config The configuration for the Table.
31
     * @return void
32
     */
33
    public function initialize(array $config)
34
    {
35
        parent::initialize($config);
36
37
        $this->table('useroptions');
0 ignored issues
show
Deprecated Code introduced by
The function Cake\ORM\Table::table() has been deprecated: 3.4.0 Use setTable()/getTable() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

37
        /** @scrutinizer ignore-deprecated */ $this->table('useroptions');

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

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

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

38
        /** @scrutinizer ignore-deprecated */ $this->displayField('name');

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

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

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

39
        /** @scrutinizer ignore-deprecated */ $this->primaryKey('id');

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

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

Loading history...
40
41
        $this->addBehavior('Timestamp');
42
43
        $this->belongsTo('Users', [
44
            'foreignKey' => 'user_id',
45
            'joinType' => 'INNER'
46
        ]);
47
    }
48
49
    /**
50
     * Default validation rules.
51
     *
52
     * @param \Cake\Validation\Validator $validator Validator instance.
53
     * @return \Cake\Validation\Validator
54
     */
55
    public function validationDefault(Validator $validator)
56
    {
57
        $validator
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Validation\Validator::allowEmpty() has been deprecated: 3.7.0 Use allowEmptyString(), allowEmptyArray(), allowEmptyFile(), allowEmptyDate(), allowEmptyTime() or allowEmptyDateTime() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

57
        /** @scrutinizer ignore-deprecated */ $validator

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

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

Loading history...
58
            ->integer('id')
59
            ->allowEmpty('id', 'create');
60
61
        $validator
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Validation\Validator::notEmpty() has been deprecated: 3.7.0 Use allowEmptyString(), allowEmptyArray(), allowEmptyFile(), allowEmptyDate(), allowEmptyTime() or allowEmptyDateTime() with reversed conditions instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

61
        /** @scrutinizer ignore-deprecated */ $validator

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

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

Loading history...
62
            ->requirePresence('name', 'create')
63
            ->notEmpty('name');
64
65
        $validator
0 ignored issues
show
Deprecated Code introduced by
The function Cake\Validation\Validator::notEmpty() has been deprecated: 3.7.0 Use allowEmptyString(), allowEmptyArray(), allowEmptyFile(), allowEmptyDate(), allowEmptyTime() or allowEmptyDateTime() with reversed conditions instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

65
        /** @scrutinizer ignore-deprecated */ $validator

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

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

Loading history...
66
            ->requirePresence('value', 'create')
67
            ->notEmpty('value');
68
69
        return $validator;
70
    }
71
72
    /**
73
     * Returns a rules checker object that will be used for validating
74
     * application integrity.
75
     *
76
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
77
     * @return \Cake\ORM\RulesChecker
78
     */
79
    public function buildRules(RulesChecker $rules)
80
    {
81
        $rules->add($rules->existsIn(['user_id'], 'Users'));
82
83
        return $rules;
84
    }
85
}
86