View::run()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 1
crap 1
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 displays an existing model.
12
 *
13
 * @author iRipVanWinkle <[email protected]>
14
 * @since 1.0
15
 */
16
class View extends BaseAction
17
{
18
    /**
19
     * @var string name of the view
20
     */
21
    public $view = 'view';
22
23
    /**
24
     * @var string the name variable model in the view template
25
     */
26
    public $nameVariableModel = 'model';
27
28
    /**
29
     * Views existing record.
30
     * @param mixed $id ID of the model to be view
31
     * @return mixed response
32
     */
33 3
    public function run($id)
34
    {
35 3
        $model = $this->getModel($id);
36
37 3
        return $this->controller->render($this->view, [
38 3
            $this->nameVariableModel => $model,
39 3
        ]);
40
    }
41
}
42