Remove   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 60
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 60
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 3

1 Method

Rating   Name   Duplication   Size   Complexity  
B delegate() 0 36 4
1
<?php
2
3
/**
4
 * Pattern for remove action
5
 *
6
 * PHP Version 5
7
 *
8
 * @category  Core
9
 * @package   RAD
10
 * @author    Hans-Joachim Piepereit <[email protected]>
11
 * @copyright 2013 cSphere Team
12
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
13
 * @link      http://www.csphere.eu
14
 **/
15
16
namespace csphere\core\rad;
17
18
/**
19
 * Pattern for remove action
20
 *
21
 * @category  Core
22
 * @package   RAD
23
 * @author    Hans-Joachim Piepereit <[email protected]>
24
 * @copyright 2013 cSphere Team
25
 * @license   http://opensource.org/licenses/bsd-license Simplified BSD License
26
 * @link      http://www.csphere.eu
27
 **/
28
29
class Remove extends \csphere\core\rad\Base
30
{
31
    /**
32
     * Action name
33
     **/
34
    protected $action = 'remove';
35
36
    /**
37
     * Template file name
38
     **/
39
    protected $tpl = 'remove';
40
41
    /**
42
     * Previous action
43
     **/
44
    protected $previous = 'manage';
45
46
    /**
47
     * Delegate action to run this method
48
     *
49
     * @return void
50
     **/
0 ignored issues
show
Coding Style introduced by
There must be no blank lines after the function comment
Loading history...
51
52
    public function delegate()
53
    {
54
        // Get record ID and sure param
55
        $record = (int)\csphere\core\http\Input::get('get', 'id');
56
        $sure   =  \csphere\core\http\Input::get('get', 'sure');
57
58
        // Get table model and record
59
        $dm_table = new \csphere\core\datamapper\Model($this->plugin, $this->table);
60
        $table    = $dm_table->read($record);
61
62
        if ($table == []) {
63
64
            $this->message('no_record_found', $record, 'red');
65
66
        } elseif ($sure == 'yes') {
67
68
            $serial         = $dm_table->serial();
69
            $table[$serial] = $record;
70
71
            $dm_table->delete($table);
72
73
            $this->message('record_deleted', $record, 'green');
74
75
        } elseif ($sure == 'no') {
76
77
            $this->message('record_cancel', $record);
78
79
        } else {
80
81
            // Data array
82
            $data  = ['rid' => $record];
83
84
            // Send data to view
85
            $this->view($data, $record);
86
        }
87
    }
88
}
89