GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

NoteController   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Importance

Changes 0
Metric Value
wmc 6
lcom 1
cbo 6
dl 0
loc 72
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 9 1
A index() 0 6 1
A create() 0 5 1
A edit() 0 6 1
A editSave() 0 5 1
A delete() 0 5 1
1
<?php
2
3
/**
4
 * The note controller: Just an example of simple create, read, update and delete (CRUD) actions.
5
 */
6
class NoteController extends Controller
7
{
8
    /**
9
     * Construct this object by extending the basic Controller class
10
     */
11
    public function __construct()
12
    {
13
        parent::__construct();
14
15
        // VERY IMPORTANT: All controllers/areas that should only be usable by logged-in users
16
        // need this line! Otherwise not-logged in users could do actions. If all of your pages should only
17
        // be usable by logged-in users: Put this line into libs/Controller->__construct
18
        Auth::checkAuthentication();
19
    }
20
21
    /**
22
     * This method controls what happens when you move to /note/index in your app.
23
     * Gets all notes (of the user).
24
     */
25
    public function index()
26
    {
27
        $this->View->render('note/index', array(
28
            'notes' => NoteModel::getAllNotes()
29
        ));
30
    }
31
32
    /**
33
     * This method controls what happens when you move to /dashboard/create in your app.
34
     * Creates a new note. This is usually the target of form submit actions.
35
     * POST request.
36
     */
37
    public function create()
38
    {
39
        NoteModel::createNote(Request::post('note_text'));
40
        Redirect::to('note');
41
    }
42
43
    /**
44
     * This method controls what happens when you move to /note/edit(/XX) in your app.
45
     * Shows the current content of the note and an editing form.
46
     * @param $note_id int id of the note
47
     */
48
    public function edit($note_id)
49
    {
50
        $this->View->render('note/edit', array(
51
            'note' => NoteModel::getNote($note_id)
52
        ));
53
    }
54
55
    /**
56
     * This method controls what happens when you move to /note/editSave in your app.
57
     * Edits a note (performs the editing after form submit).
58
     * POST request.
59
     */
60
    public function editSave()
61
    {
62
        NoteModel::updateNote(Request::post('note_id'), Request::post('note_text'));
63
        Redirect::to('note');
64
    }
65
66
    /**
67
     * This method controls what happens when you move to /note/delete(/XX) in your app.
68
     * Deletes a note. In a real application a deletion via GET/URL is not recommended, but for demo purposes it's
69
     * totally okay.
70
     * @param int $note_id id of the note
71
     */
72
    public function delete($note_id)
73
    {
74
        NoteModel::deleteNote($note_id);
75
        Redirect::to('note');
76
    }
77
}
78