TicketstatusesController::add()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
cc 3
eloc 9
c 0
b 0
f 0
nc 3
nop 0
dl 0
loc 14
ccs 0
cts 10
cp 0
crap 12
rs 9.9666
1
<?php
0 ignored issues
show
Coding Style introduced by
Filename "TicketstatusesController.php" doesn't match the expected filename "ticketstatusescontroller.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\Admin;
0 ignored issues
show
Coding Style introduced by
Missing file doc comment
Loading history...
3
4
use App\Controller\AppController;
5
6
/**
7
 * Ticketstatuses Controller
8
 *
9
 * @property \App\Model\Table\TicketstatusesTable $Ticketstatuses
10
 */
0 ignored issues
show
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 @package tag in class comment
Loading history...
Coding Style introduced by
Missing @category tag in class comment
Loading history...
11
class TicketstatusesController extends AppController
12
{
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration for class TicketstatusesController
Loading history...
introduced by
Opening brace should be on the same line as the declaration
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 1
    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 1
        $ticketstatuses = $this->paginate($this->Ticketstatuses);
22
23 1
        $this->set(compact('ticketstatuses'));
24 1
        $this->set('_serialize', ['ticketstatuses']);
25 1
    }
26
27
    /**
28
     * View method
29
     *
30
     * @param string|null $id Ticketstatus id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
31
     * @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...
introduced by
Separate the @param and @return sections by a blank line.
Loading history...
32
     * @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...
33
     */
34
    public function view($id = null)
35
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
36
        $ticketstatus = $this->Ticketstatuses->get($id, [
37
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
38
        ]);
39
40
        $this->set('ticketstatus', $ticketstatus);
41
        $this->set('_serialize', ['ticketstatus']);
42
    }
43
44
    /**
45
     * Add method
46
     *
47
     * @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise.
48
     */
49
    public function add()
50
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
51
        $ticketstatus = $this->Ticketstatuses->newEmptyEntity();
52
        if ($this->request->is('post')) {
53
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, $this->getRequest()->getData());
54
            if ($this->Ticketstatuses->save($ticketstatus)) {
55
                $this->Flash->success(__('The ticketstatus has been saved.'));
56
57
                return $this->redirect(['prefix'=>'Admin', 'controller'=>'Ticketstatuses', 'action' => 'index']);
0 ignored issues
show
Coding Style introduced by
Expected 1 space between double arrow and "'Ticketstatuses'"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between "'controller'" and double arrow; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between double arrow and "'Admin'"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between "'prefix'" and double arrow; 0 found
Loading history...
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space before "=>"; 0 found
Loading history...
58
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
59
            $this->Flash->error(__('The ticketstatus could not be saved. Please, try again.'));
60
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
61
        $this->set(compact('ticketstatus'));
62
        $this->set('_serialize', ['ticketstatus']);
63
    }
64
65
    /**
66
     * Edit method
67
     *
68
     * @param string|null $id Ticketstatus id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
69
     * @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...
70
     * @throws \Cake\Network\Exception\NotFoundException 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...
71
     */
72
    public function edit($id = null)
73
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
74
        $ticketstatus = $this->Ticketstatuses->get($id, [
75
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
76
        ]);
77
        if ($this->request->is(['patch', 'post', 'put'])) {
78
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, $this->request->data);
79
            if ($this->Ticketstatuses->save($ticketstatus)) {
80
                $this->Flash->success(__('The ticketstatus has been saved.'));
81
82
                return $this->redirect(['prefix'=>false, 'controller'=>'Ticketstatuses', 'action' => 'index']);
0 ignored issues
show
Coding Style introduced by
Expected at least 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between double arrow and "false"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between "'prefix'" and double arrow; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between double arrow and "'Ticketstatuses'"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between "'controller'" and double arrow; 0 found
Loading history...
83
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
84
            $this->Flash->error(__('The ticketstatus could not be saved. Please, try again.'));
85
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
86
        $this->set(compact('ticketstatus'));
87
        $this->set('_serialize', ['ticketstatus']);
88
    }
89
90
    /**
91
     * Delete method
92
     *
93
     * @param string|null $id Ticketstatus id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
94
     * @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...
95
     * @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...
96
     */
97
    public function delete($id = null)
98
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
99
        $this->request->allowMethod(['post', 'delete']);
100
        $ticketstatus = $this->Ticketstatuses->get($id);
101
        if ($this->Ticketstatuses->delete($ticketstatus)) {
102
            $this->Flash->success(__('The ticketstatus has been deleted.'));
103
        } else {
0 ignored issues
show
introduced by
Expected newline after closing brace
Loading history...
104
            $this->Flash->error(__('The ticketstatus could not be deleted. Please, try again.'));
105
        }
106
107
        return $this->redirect(['prefix'=>false, 'controller'=>'Ticketstatuses', 'action' => 'index']);
0 ignored issues
show
Coding Style introduced by
Expected 1 space between "'prefix'" and double arrow; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between double arrow and "false"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space after "=>"; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space before "=>"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between double arrow and "'Ticketstatuses'"; 0 found
Loading history...
Coding Style introduced by
Expected 1 space between "'controller'" and double arrow; 0 found
Loading history...
Coding Style introduced by
Expected at least 1 space after "=>"; 0 found
Loading history...
108
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
109
}
110