Passed
Pull Request — master (#8)
by Brian
06:08
created

AppController   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 16
dl 0
loc 50
ccs 0
cts 22
cp 0
rs 10
c 2
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 21 4
A thankyou() 0 2 1
1
<?php
2
3
/**
4
 * AppController
5
 */
6
7
namespace Fr3nch13\Jira\Controller;
8
9
use App\Controller\AppController as BaseController;
10
11
/**
12
 * App Controller
13
 *
14
 * The base controller for the jira plugin.
15
 *
16
 * -----------------------------
17
 * Inherited:
18
 *
19
 * {@inheritdoc}
20
 */
21
class AppController extends BaseController
22
{
23
    /**
24
     * Human name of this object.
25
     * @var string
26
     */
27
    public $humanName = '';
28
29
    /**
30
     * The form object.
31
     * @var object|null
32
     */
33
    public $JiraForm = null;
34
35
    /**
36
     * The html form.
37
     *
38
     * @return void|\Cake\Http\Response|null Redirects on success.
39
     */
40
    public function add()
41
    {
42
        $errors = [];
43
        if ($this->getRequest()->is('post')) {
44
            if ($this->JiraForm->execute($this->getRequest()->getData())) {
45
                $this->Flash->success(__('The {0} has been saved.', [$this->humanName]));
46
47
                return $this->redirect(['action' => 'thankyou', '?' => ['type' => $this->humanName]]);
48
            } else {
49
                $errors = $this->JiraForm->getErrors();
50
                $this->Flash->error(__('There was a problem saving the {0}.', [$this->humanName]));
51
            }
52
        }
53
54
        if ($this->getRequest()->is('get')) {
55
            $this->JiraForm->setData($this->JiraForm->getFormData());
56
        }
57
58
        $this->set([
59
            'form' => $this->JiraForm,
60
            'errors' => $errors
61
        ]);
62
    }
63
64
    /**
65
     * The thank you page after they've submitted their report.
66
     *
67
     * @return void
68
     */
69
    public function thankyou()
70
    {
71
        //
72
    }
73
}
74