OrganizationsTable   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 20
c 1
b 0
f 0
dl 0
loc 58
ccs 0
cts 20
cp 0
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A buildRules() 0 5 1
A initialize() 0 13 1
A validationDefault() 0 13 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
Coding Style introduced by
Filename "OrganizationsTable.php" doesn't match the expected filename "organizationstable.php"
Loading history...
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Header blocks must be separated by a single blank line
Loading history...
Coding Style introduced by
This file is missing a doc comment.
Loading history...
2
namespace App\Model\Table;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use Cake\ORM\Query;
0 ignored issues
show
introduced by
Unused use statement
Loading history...
5
use Cake\ORM\RulesChecker;
6
use Cake\ORM\Table;
7
use Cake\Validation\Validator;
8
9
/**
10
 * Organizations Model
11
 *
12
 * @property \App\Model\Table\UsersTable|\Cake\ORM\Association\BelongsTo $Users
13
 *
14
 * @method \App\Model\Entity\Organization get($primaryKey, $options = [])
15
 * @method \App\Model\Entity\Organization newEntity($data = null, array $options = [])
16
 * @method \App\Model\Entity\Organization[] newEntities(array $data, array $options = [])
17
 * @method \App\Model\Entity\Organization|bool save(\Cake\Datasource\EntityInterface $entity, $options = [])
18
 * @method \App\Model\Entity\Organization patchEntity(\Cake\Datasource\EntityInterface $entity, array $data, array $options = [])
19
 * @method \App\Model\Entity\Organization[] patchEntities($entities, array $data, array $options = [])
20
 * @method \App\Model\Entity\Organization findOrCreate($search, callable $callback = null, $options = [])
21
 *
22
 * @mixin \Cake\ORM\Behavior\TimestampBehavior
23
 */
0 ignored issues
show
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
24
class OrganizationsTable extends Table
25
{
0 ignored issues
show
introduced by
Opening brace should be on the same line as the declaration
Loading history...
Coding Style introduced by
Opening brace should be on the same line as the declaration for class OrganizationsTable
Loading history...
26
27
    /**
28
     * Initialize method
29
     *
30
     * @param array $config The configuration for the Table.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
31
     * @return void
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
introduced by
If there is no return value for a function, there must not be a @return tag.
Loading history...
32
     */
33
    public function initialize(array $config) : void
0 ignored issues
show
Coding Style introduced by
There must not be a space before the colon in a return type declaration
Loading history...
34
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
35
        parent::initialize($config);
36
37
        $this->setTable('organizations');
38
        $this->setDisplayField('name');
39
        $this->setPrimaryKey('id');
40
41
        $this->addBehavior('Timestamp');
42
43
        $this->belongsTo('Users', [
44
            'foreignKey' => 'user_id',
45
            'joinType' => 'INNER'
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: 'INNER'
Loading history...
46
        ]);
47
    }
48
49
    /**
50
     * Default validation rules.
51
     *
52
     * @param \Cake\Validation\Validator $validator Validator instance.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
53
     * @return \Cake\Validation\Validator
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
54
     */
55
    public function validationDefault(Validator $validator) : Validator
0 ignored issues
show
Coding Style introduced by
There must not be a space before the colon in a return type declaration
Loading history...
56
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
57
        $validator
58
            ->integer('id')
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 12
Loading history...
59
            ->allowEmpty('id', 'create');
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
60
61
        $validator
62
            ->scalar('name')
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
introduced by
Object operator not indented correctly; expected 10 spaces but found 12
Loading history...
63
            ->maxLength('name', 255)
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
64
            ->requirePresence('name', 'create')
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
65
            ->notEmpty('name');
0 ignored issues
show
Coding Style introduced by
Space found before object operator
Loading history...
66
67
        return $validator;
68
    }
69
70
    /**
71
     * Returns a rules checker object that will be used for validating
72
     * application integrity.
0 ignored issues
show
introduced by
Doc comment short description must be on a single line, further text should be a separate paragraph
Loading history...
73
     *
74
     * @param \Cake\ORM\RulesChecker $rules The rules object to be modified.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
75
     * @return \Cake\ORM\RulesChecker
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
76
     */
77
    public function buildRules(RulesChecker $rules) : RulesChecker
0 ignored issues
show
Coding Style introduced by
There must not be a space before the colon in a return type declaration
Loading history...
78
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
79
        $rules->add($rules->existsIn(['user_id'], 'Users'));
80
81
        return $rules;
82
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
83
}
84