Delete   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 3
Bugs 1 Features 1
Metric Value
wmc 2
c 3
b 1
f 1
lcom 1
cbo 1
dl 0
loc 33
ccs 6
cts 7
cp 0.8571
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 2
1
<?php
2
/**
3
 * @link https://github.com/roboapp
4
 * @copyright Copyright (c) 2016 Roboapp
5
 * @license [MIT License](https://opensource.org/licenses/MIT)
6
 */
7
8
namespace roboapp\crud;
9
10
/**
11
 * Action performs the hard or soft deleting of the existing record.
12
 *
13
 * @author iRipVanWinkle <[email protected]>
14
 * @since 1.0
15
 */
16
class Delete extends BaseAction
17
{
18
    /**
19
     * Method name for hard delete model
20
     */
21
    const METHOD_HARD = 'delete';
22
23
    /**
24
     * Method name for soft delete model
25
     */
26
    const METHOD_SOFT = 'softDelete';
27
28
    /**
29
     * @var string method name for delete model.
30
     */
31
    public $methodName = self::METHOD_HARD;
32
33
    /**
34
     * Deletes model
35
     * @param mixed $id ID of the model to be deleted
36
     * @return mixed
37
     */
38 6
    public function run($id)
39
    {
40 6
        $model = $this->getModel($id);
41 6
42 6
        if ($model->{$this->methodName}()) {
43 6
            $this->addSuccessFlash();
44
        }
45
46
        return $this->redirect($model);
47 6
    }
48
}
49