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

TicketstatusesController   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 97
Duplicated Lines 0 %

Test Coverage

Coverage 12.2%

Importance

Changes 0
Metric Value
eloc 34
c 0
b 0
f 0
dl 0
loc 97
ccs 5
cts 41
cp 0.122
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 14 3
A index() 0 6 1
A delete() 0 11 2
A view() 0 8 1
A edit() 0 16 3
1
<?php
2
namespace App\Controller\Admin;
3
4
use App\Controller\AppController;
5
6
/**
7
 * Ticketstatuses Controller
8
 *
9
 * @property \App\Model\Table\TicketstatusesTable $Ticketstatuses
10
 */
11
class TicketstatusesController extends AppController
12
{
13
14
    /**
15
     * Index method
16
     *
17
     * @return \Cake\Network\Response|null
18
     */
19 1
    public function index()
20
    {
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.
31
     * @return \Cake\Network\Response|null
32
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
33
     */
34
    public function view($id = null)
35
    {
36
        $ticketstatus = $this->Ticketstatuses->get($id, [
37
            'contain' => []
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
    {
51
        $ticketstatus = $this->Ticketstatuses->newEntity();
52
        if ($this->request->is('post')) {
53
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, $this->request->data);
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Http\ServerRequest::$data has been deprecated: 3.4.0 This public property will be removed in 4.0.0. Use getData() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

53
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, /** @scrutinizer ignore-deprecated */ $this->request->data);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Bug introduced by
It seems like $this->request->data can also be of type object; however, parameter $data of App\Model\Table\TicketstatusesTable::patchEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

53
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, /** @scrutinizer ignore-type */ $this->request->data);
Loading history...
54
            if ($this->Ticketstatuses->save($ticketstatus)) {
55
                $this->Flash->success(__('The ticketstatus has been saved.'));
56
57
                return $this->redirect(['prefix'=>false, 'controller'=>'Ticketstatuses', 'action' => 'index']);
58
            }
59
            $this->Flash->error(__('The ticketstatus could not be saved. Please, try again.'));
60
        }
61
        $this->set(compact('ticketstatus'));
62
        $this->set('_serialize', ['ticketstatus']);
63
    }
64
65
    /**
66
     * Edit method
67
     *
68
     * @param string|null $id Ticketstatus id.
69
     * @return \Cake\Network\Response|null Redirects on successful edit, renders view otherwise.
70
     * @throws \Cake\Network\Exception\NotFoundException When record not found.
71
     */
72
    public function edit($id = null)
73
    {
74
        $ticketstatus = $this->Ticketstatuses->get($id, [
75
            'contain' => []
76
        ]);
77
        if ($this->request->is(['patch', 'post', 'put'])) {
78
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, $this->request->data);
0 ignored issues
show
Deprecated Code introduced by
The property Cake\Http\ServerRequest::$data has been deprecated: 3.4.0 This public property will be removed in 4.0.0. Use getData() instead. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

78
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, /** @scrutinizer ignore-deprecated */ $this->request->data);

This property has been deprecated. The supplier of the class has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead.

Loading history...
Bug introduced by
It seems like $this->request->data can also be of type object; however, parameter $data of App\Model\Table\TicketstatusesTable::patchEntity() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

78
            $ticketstatus = $this->Ticketstatuses->patchEntity($ticketstatus, /** @scrutinizer ignore-type */ $this->request->data);
Loading history...
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']);
83
            }
84
            $this->Flash->error(__('The ticketstatus could not be saved. Please, try again.'));
85
        }
86
        $this->set(compact('ticketstatus'));
87
        $this->set('_serialize', ['ticketstatus']);
88
    }
89
90
    /**
91
     * Delete method
92
     *
93
     * @param string|null $id Ticketstatus id.
94
     * @return \Cake\Network\Response|null Redirects to index.
95
     * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found.
96
     */
97
    public function delete($id = null)
98
    {
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 {
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']);
108
    }
109
}
110