Restore::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2.0932

Importance

Changes 3
Bugs 1 Features 1
Metric Value
c 3
b 1
f 1
dl 0
loc 10
ccs 5
cts 7
cp 0.7143
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 2.0932
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
 * Actions performs restoration of the soft deleted record.
12
 * This action supports [roboapp/softdelete](https://github.com/roboapp/softdelete) extension.
13
 *
14
 * @see https://github.com/roboapp/softdelete
15
 *
16
 * @author iRipVanWinkle <[email protected]>
17
 * @since 1.0
18
 */
19
class Restore extends BaseAction
20
{
21
    /**
22
     * Restore model
23
     * @param mixed $id ID of the model to be restored.
24
     * @return mixed
25
     */
26 3
    public function run($id)
27
    {
28 3
        $model = $this->getModel($id);
29 3
        
30
        if ($model->restore()) {
31
            $this->addSuccessFlash();
32 3
        }
33
34
        return $this->redirect($model);
35 3
    }
36
}
37