Completed
Push — develop ( 1c3d8e...dc7d05 )
by Mohamed
07:44
created

Note::actions()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 6
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 9.4285
cc 2
eloc 3
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the Tinyissue package.
5
 *
6
 * (c) Mohamed Alsharaf <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Tinyissue\Form;
13
14
/**
15
 * Note is a class to defines fields & rules for add/edit note form.
16
 *
17
 * @author Mohamed Alsharaf <[email protected]>
18
 */
19
class Note extends FormAbstract
20
{
21
    /**
22
     * An instance of project model.
23
     *
24
     * @var \Tinyissue\Model\Project
25
     */
26
    protected $project;
27
28
    /**
29
     * @param array $params
30
     *
31
     * @return void
32
     */
33 7
    public function setup(array $params)
34
    {
35 7
        $this->project = $params['project'];
36 7
    }
37
38
    /**
39
     * @return array
40
     */
41 5
    public function actions()
42
    {
43
        return [
44 5
            'submit' => $this->isEditing() ? 'update' : 'save',
45
        ];
46
    }
47
48
    /**
49
     * @return array
50
     */
51 5
    public function fields()
52
    {
53
        $fields = [
54
            'note_body' => [
55
                'type' => 'textarea',
56
                'help' => '<a href="http://daringfireball.net/projects/markdown/basics/" target="_blank">Format with Markdown</a>',
57 5
            ],
58
        ];
59
60 5
        return $fields;
61
    }
62
63
    /**
64
     * @return array
65
     */
66 5
    public function rules()
67
    {
68
        $rules = [
69 5
            'note_body' => 'required',
70
        ];
71
72 5
        return $rules;
73
    }
74
75
    /**
76
     * @return string
77
     */
78
    public function getRedirectUrl()
79
    {
80
        return $this->project->to('notes');
81
    }
82
}
83