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

OperationsTable::validationDefault()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 20
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 14
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 20
ccs 11
cts 11
cp 1
crap 1
rs 9.7998
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
 * Operations Model
11
 *
12
 * @property \Cake\ORM\Association\BelongsTo $Tickets
13
 *
14
 * @method \App\Model\Entity\Operation get($primaryKey, $options = [])
15
 * @method \App\Model\Entity\Operation newEntity($data = null, array $options = [])
16
 * @method \App\Model\Entity\Operation[] newEntities(array $data, array $options = [])
17
 * @method \App\Model\Entity\Operation|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
18
 * @method \App\Model\Entity\Operation patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19
 * @method \App\Model\Entity\Operation[] patchEntities($entities, array $data, array $options = [])
20
 * @method \App\Model\Entity\Operation findOrCreate($search, callable $callback = null, $options = [])
21
 *
22
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
23
 */
24
class OperationsTable extends Table
25
{
26
27
    /**
28
     * Initialize method
29
     *
30
     * @param array $config The configuration for the Table.
31
     * @return void
32
     */
33 4
    public function initialize(array $config)
34
    {
35 4
        parent::initialize($config);
36
37 4
        $this->table('operations');
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('operations');

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 4
        $this->displayField('id');
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('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...
39 4
        $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 4
        $this->addBehavior('Timestamp');
42
43 4
        $this->belongsTo('Tickets', [
44 4
            'foreignKey' => 'ticket_id',
45
            'joinType' => 'INNER'
46
        ]);
47 4
    }
48
49
    /**
50
     * Default validation rules.
51
     *
52
     * @param \Cake\Validation\Validator $validator Validator instance.
53
     * @return \Cake\Validation\Validator
54
     */
55 2
    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 2
            ->integer('id')
59 2
            ->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 2
            ->dateTime('start')
63 2
            ->requirePresence('start', 'create')
64 2
            ->notEmpty('start');
65
66
        $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

66
        /** @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...
67 2
            ->dateTime('end')
68 2
            ->requirePresence('end', 'create')
69 2
            ->notEmpty('end');
70
71
        $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

71
        /** @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...
72 2
            ->allowEmpty('description', 'create');
73
			
74 2
        return $validator;
75
    }
76
77
    /**
78
     * Returns a rules checker object that will be used for validating
79
     * application integrity.
80
     *
81
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
82
     * @return \Cake\ORM\RulesChecker
83
     */
84 1
    public function buildRules(RulesChecker $rules)
85
    {
86 1
        $rules->add($rules->existsIn(['ticket_id'], 'Tickets'));
87
88 1
        return $rules;
89
    }
90
}
91