TickettypesController   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Test Coverage

Coverage 28.57%

Importance

Changes 0
Metric Value
eloc 35
c 0
b 0
f 0
dl 0
loc 99
ccs 12
cts 42
cp 0.2857
rs 10
wmc 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A view() 0 8 1
A edit() 0 16 3
A delete() 0 11 2
A index() 0 8 1
A add() 0 14 3
1
<?php
0 ignored issues
show
Coding Style introduced by
Filename "TickettypesController.php" doesn't match the expected filename "tickettypescontroller.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
 * Tickettypes Controller
8
 *
9
 * @property \App\Model\Table\TickettypesTable $Tickettypes
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 TickettypesController 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 TickettypesController
Loading history...
13
14
    /**
15
     * Index method
16
     *
17
     * @return \Cake\Network\Response|null
0 ignored issues
show
introduced by
Function return type is not void, but function has no return statement
Loading history...
introduced by
@return doc comment specified, 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
        $tickettypes = $this->paginate($this->Tickettypes);
22
		
23 1
		$title = "Type of ticket";
0 ignored issues
show
Coding Style introduced by
Line indented incorrectly; expected at least 8 spaces, found 2
Loading history...
Coding Style Comprehensibility introduced by
The string literal Type of ticket does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
24
25 1
        $this->set(compact(['tickettypes', 'title']));
26 1
        $this->set('_serialize', ['tickettypes']);
27 1
    }
28
29
    /**
30
     * View method
31
     *
32
     * @param string|null $id Tickettype id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
33
     * @return \Cake\Network\Response|null
0 ignored issues
show
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...
introduced by
@return doc comment specified, but function has no return statement
Loading history...
34
     * @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...
35
     */
36
    public function view($id = null)
37
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
38
        $tickettype = $this->Tickettypes->get($id, [
39
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
40
        ]);
41
42
        $this->set('tickettype', $tickettype);
43
        $this->set('_serialize', ['tickettype']);
44
    }
45
46
    /**
47
     * Add method
48
     *
49
     * @return \Cake\Network\Response|null Redirects on successful add, renders view otherwise.
50
     */
51
    public function add()
52
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
53
        $tickettype = $this->Tickettypes->newEmptyEntity();
54
        if ($this->request->is('post')) {
55
            $tickettype = $this->Tickettypes->patchEntity($tickettype, $this->getRequest()->getData());
56
            if ($this->Tickettypes->save($tickettype)) {
57
                $this->Flash->success(__('The tickettype has been saved.'));
58
59
                return $this->redirect(['prefix'=>'Admin', 'controller'=>'Tickettypes', 'action' => 'index']);
0 ignored issues
show
Coding Style introduced by
Expected 1 space between double arrow and "'Admin'"; 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 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 at least 1 space after "=>"; 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 "'Tickettypes'"; 0 found
Loading history...
60
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
61
            $this->Flash->error(__('The tickettype could not be saved. Please, try again.'));
62
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
63
        $this->set(compact('tickettype'));
64
        $this->set('_serialize', ['tickettype']);
65
    }
66
67
    /**
68
     * Edit method
69
     *
70
     * @param string|null $id Tickettype id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
71
     * @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...
72
     * @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...
73
     */
74
    public function edit($id = null)
75
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
76
        $tickettype = $this->Tickettypes->get($id, [
77
            'contain' => []
0 ignored issues
show
introduced by
A comma should follow the last multiline array item. Found: ]
Loading history...
78
        ]);
79
        if ($this->request->is(['patch', 'post', 'put'])) {
80
            $tickettype = $this->Tickettypes->patchEntity($tickettype, $this->request->data);
81
            if ($this->Tickettypes->save($tickettype)) {
82
                $this->Flash->success(__('The tickettype has been saved.'));
83
84
                return $this->redirect(['prefix'=>false, 'controller'=>'Tickettypes', '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 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 "'controller'" 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 between double arrow and "'Tickettypes'"; 0 found
Loading history...
85
            }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
86
            $this->Flash->error(__('The tickettype could not be saved. Please, try again.'));
87
        }
0 ignored issues
show
Coding Style introduced by
No blank line found after control structure
Loading history...
88
        $this->set(compact('tickettype'));
89
        $this->set('_serialize', ['tickettype']);
90
    }
91
92
    /**
93
     * Delete method
94
     *
95
     * @param string|null $id Tickettype id.
0 ignored issues
show
introduced by
Parameter comment must be on the next line
Loading history...
96
     * @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...
97
     * @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...
98
     */
99 1
    public function delete($id = null)
100
    {
0 ignored issues
show
Coding Style introduced by
Opening brace should be on the same line as the declaration
Loading history...
101 1
        $this->request->allowMethod(['post', 'delete']);
102 1
        $tickettype = $this->Tickettypes->get($id);
103 1
        if ($this->Tickettypes->delete($tickettype)) {
104 1
            $this->Flash->success(__('The tickettype has been deleted.'));
105
        } else {
0 ignored issues
show
introduced by
Expected newline after closing brace
Loading history...
106
            $this->Flash->error(__('The tickettype could not be deleted. Please, try again.'));
107
        }
108
109 1
        return $this->redirect(['prefix'=>false, 'controller'=>'Tickettypes', 'action' => 'index']);
0 ignored issues
show
Coding Style introduced by
Expected 1 space between double arrow and "'Tickettypes'"; 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...
Coding Style introduced by
Expected at least 1 space before "=>"; 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 "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...
110
    }
0 ignored issues
show
Coding Style introduced by
Expected 1 blank line after function; 0 found
Loading history...
111
}
112