Completed
Push — develop ( a45eac...0b88af )
by Mohamed
02:46
created

Note   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 88.89%

Importance

Changes 3
Bugs 0 Features 3
Metric Value
wmc 6
c 3
b 0
f 3
lcom 1
cbo 2
dl 0
loc 64
ccs 16
cts 18
cp 0.8889
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setup() 0 4 1
A actions() 0 6 2
A fields() 0 11 1
A rules() 0 8 1
A getRedirectUrl() 0 4 1
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 5
        ];
46
    }
47
48
    /**
49
     * @return array
50
     */
51 5
    public function fields()
52
    {
53
        $fields = [
54
            'note_body' => [
55 5
                'type' => 'textarea',
56 5
                'help' => '<a href="http://daringfireball.net/projects/markdown/basics/" target="_blank">Format with Markdown</a>',
57 5
            ],
58 5
        ];
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 5
        ];
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