OrganizationsController   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 98
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 34
c 1
b 0
f 0
dl 0
loc 98
ccs 0
cts 35
cp 0
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A view() 0 7 1
A add() 0 14 3
A delete() 0 11 2
A edit() 0 16 3
A index() 0 8 1
1
<?php
0 ignored issues
show
Coding Style introduced by
Filename "OrganizationsController.php" doesn't match the expected filename "organizationscontroller.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...
Coding Style introduced by
Class found in ".php" file; use ".inc" extension instead
Loading history...
2
namespace App\Controller;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use App\Controller\AppController;
0 ignored issues
show
introduced by
Unused use statement
Loading history...
5
6
/**
7
 * Organizations Controller
8
 *
9
 * @property \App\Model\Table\OrganizationsTable $Organizations
10
 *
11
 * @method \App\Model\Entity\Organization[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = [])
12
 */
0 ignored issues
show
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
13
class OrganizationsController extends AppController
14
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class OrganizationsController
Loading history...
introduced by
Opening brace should be on the same line as the declaration
Loading history...
15
16
    /**
17
     * Index method
18
     *
19
     * @return \Cake\Http\Response|void
0 ignored issues
show
introduced by
@return doc comment specified, but function has no return statement
Loading history...
20
     */
21
    public function index()
22
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
23
        $this->paginate = [
24
            'contain' => ['Users']
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
25
        ];
26
        $organizations = $this->paginate($this->Organizations);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
27
28
        $this->set(compact('organizations'));
29
    }
30
31
    /**
32
     * View method
33
     *
34
     * @param string|null $id Organization id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
35
     * @return \Cake\Http\Response|void
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
introduced by
@return doc comment specified, but function has no return statement
Loading history...
36
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
0 ignored issues
show
introduced by
@throws comment must be on the next line
Loading history...
introduced by
Separate the @return and @throws sections by a blank line.
Loading history...
37
     */
38
    public function view($id = null)
39
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
40
        $organization = $this->Organizations->get($id, [
41
            'contain' => ['Users']
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
42
        ]);
43
44
        $this->set('organization', $organization);
45
    }
46
47
    /**
48
     * Add method
49
     *
50
     * @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise.
51
     */
52
    public function add()
53
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
54
        $organization = $this->Organizations->newEntity();
55
        if ($this->request->is('post')) {
56
            $organization = $this->Organizations->patchEntity($organization, $this->request->getData());
57
            if ($this->Organizations->save($organization)) {
58
                $this->Flash->success(__('The organization has been saved.'));
59
60
                return $this->redirect(['action' => 'index']);
61
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
62
            $this->Flash->error(__('The organization could not be saved. Please, try again.'));
63
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
64
        $users = $this->Organizations->Users->find('list', ['limit' => 200]);
65
        $this->set(compact('organization', 'users'));
66
    }
67
68
    /**
69
     * Edit method
70
     *
71
     * @param string|null $id Organization id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
72
     * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise.
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
73
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
0 ignored issues
show
introduced by
Separate the @return and @throws sections by a blank line.
Loading history...
introduced by
@throws comment must be on the next line
Loading history...
74
     */
75
    public function edit($id = null)
76
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
77
        $organization = $this->Organizations->get($id, [
78
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
79
        ]);
80
        if ($this->request->is(['patch', 'post', 'put'])) {
81
            $organization = $this->Organizations->patchEntity($organization, $this->request->getData());
82
            if ($this->Organizations->save($organization)) {
83
                $this->Flash->success(__('The organization has been saved.'));
84
85
                return $this->redirect(['action' => 'index']);
86
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
87
            $this->Flash->error(__('The organization could not be saved. Please, try again.'));
88
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
89
        $users = $this->Organizations->Users->find('list', ['limit' => 200]);
90
        $this->set(compact('organization', 'users'));
91
    }
92
93
    /**
94
     * Delete method
95
     *
96
     * @param string|null $id Organization id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
97
     * @return \Cake\Http\Response|null Redirects to index.
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
98
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
0 ignored issues
show
introduced by
@throws comment must be on the next line
Loading history...
introduced by
Separate the @return and @throws sections by a blank line.
Loading history...
99
     */
100
    public function delete($id = null)
101
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
102
        $this->request->allowMethod(['post', 'delete']);
103
        $organization = $this->Organizations->get($id);
104
        if ($this->Organizations->delete($organization)) {
105
            $this->Flash->success(__('The organization has been deleted.'));
106
        } else {
0 ignored issues
show
introduced by
Expected newline after closing brace
Loading history...
107
            $this->Flash->error(__('The organization could not be deleted. Please, try again.'));
108
        }
109
110
        return $this->redirect(['action' => 'index']);
111
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
112
}
113