UseroptionsController   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 102
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 38
c 1
b 0
f 0
dl 0
loc 102
ccs 0
cts 39
cp 0
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A edit() 0 17 3
A index() 0 9 1
A view() 0 8 1
A delete() 0 11 2
A add() 0 15 3
1
<?php
0 ignored issues
show
Coding Style introduced by
The PHP open tag does not have a corresponding PHP close tag
Loading history...
Coding Style introduced by
Filename "UseroptionsController.php" doesn't match the expected filename "useroptionscontroller.php"
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
 * Useroptions Controller
8
 *
9
 * @property \App\Model\Table\UseroptionsTable $Useroptions
10
 */
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...
11
class UseroptionsController extends AppController
12
{
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 UseroptionsController
Loading history...
13
14
    /**
15
     * Index method
16
     *
17
     * @return \Cake\Network\Response|null
0 ignored issues
show
introduced by
@return doc comment specified, but function has no return statement
Loading history...
introduced by
Function return type is not void, but function has no return statement
Loading history...
18
     */
19
    public function index()
20
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
21
        $this->paginate = [
22
            'contain' => ['Users']
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
23
        ];
24
        $useroptions = $this->paginate($this->Useroptions);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 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...
25
26
        $this->set(compact('useroptions'));
27
        $this->set('_serialize', ['useroptions']);
28
    }
29
30
    /**
31
     * View method
32
     *
33
     * @param string|null $id Useroption id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
34
     * @return \Cake\Network\Response|null
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...
introduced by
Function return type is not void, but function has no return statement
Loading history...
35
     * @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...
36
     */
37
    public function view($id = null)
38
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
39
        $useroption = $this->Useroptions->get($id, [
40
            'contain' => ['Users']
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
41
        ]);
42
43
        $this->set('useroption', $useroption);
44
        $this->set('_serialize', ['useroption']);
45
    }
46
47
    /**
48
     * Add method
49
     *
50
     * @return \Cake\Network\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
        $useroption = $this->Useroptions->newEntity();
55
        if ($this->request->is('post')) {
56
            $useroption = $this->Useroptions->patchEntity($useroption, $this->request->data);
57
            if ($this->Useroptions->save($useroption)) {
58
                $this->Flash->success(__('The useroption 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 useroption 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->Useroptions->Users->find('list', ['limit' => 200]);
65
        $this->set(compact('useroption', 'users'));
66
        $this->set('_serialize', ['useroption']);
67
    }
68
69
    /**
70
     * Edit method
71
     *
72
     * @param string|null $id Useroption id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
73
     * @return \Cake\Network\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...
74
     * @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...
75
     */
76
    public function edit($id = null)
77
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
78
        $useroption = $this->Useroptions->get($id, [
79
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
80
        ]);
81
        if ($this->request->is(['patch', 'post', 'put'])) {
82
            $useroption = $this->Useroptions->patchEntity($useroption, $this->request->data);
83
            if ($this->Useroptions->save($useroption)) {
84
                $this->Flash->success(__('The useroption has been saved.'));
85
86
                return $this->redirect(['action' => 'index']);
87
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
88
            $this->Flash->error(__('The useroption could not be saved. Please, try again.'));
89
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
90
        $users = $this->Useroptions->Users->find('list', ['limit' => 200]);
91
        $this->set(compact('useroption', 'users'));
92
        $this->set('_serialize', ['useroption']);
93
    }
94
95
    /**
96
     * Delete method
97
     *
98
     * @param string|null $id Useroption id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
99
     * @return \Cake\Network\Response|null Redirects to index.
0 ignored issues
show
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
100
     * @throws \Cake\Datasource\Exception\RecordNotFoundException 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...
101
     */
102
    public function delete($id = null)
103
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
104
        $this->request->allowMethod(['post', 'delete']);
105
        $useroption = $this->Useroptions->get($id);
106
        if ($this->Useroptions->delete($useroption)) {
107
            $this->Flash->success(__('The useroption has been deleted.'));
108
        } else {
0 ignored issues
show
introduced by
Expected newline after closing brace
Loading history...
109
            $this->Flash->error(__('The useroption could not be deleted. Please, try again.'));
110
        }
111
112
        return $this->redirect(['action' => 'index']);
113
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
114
}
115