ViewLogAction   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 24
ccs 0
cts 8
cp 0
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 10 3
1
<?php
2
/**
3
 * @copyright Copyright(c) 2016 Webtools Ltd
4
 * @copyright Copyright(c) 2018 Thamtech, LLC
5
 * @link https://github.com/thamtech/yii2-scheduler
6
 * @license https://opensource.org/licenses/MIT
7
**/
8
9
namespace thamtech\scheduler\actions;
10
11
use Yii;
12
use yii\base\Action;
13
use thamtech\scheduler\models\SchedulerLog;
14
15
/**
16
 * View a log entry.
17
 */
18
class ViewLogAction extends Action
19
{
20
    /**
21
     * @var string the view file to be rendered. If not set, it will take the value of [[id]].
22
     * That means, if you name the action as "index" in "SchedulerController", then the view name
23
     * would be "index", and the corresponding view file would be "views/scheduler/index.php".
24
     */
25
    public $view;
26
27
    /**
28
     * Runs the action
29
     *
30
     * @return string result content
31
     */
32
    public function run($id)
33
    {
34
        $model = SchedulerLog::findOne($id);
35
36
        if (!$model) {
0 ignored issues
show
introduced by
$model is of type yii\db\ActiveRecord, thus it always evaluated to true.
Loading history...
37
            throw new \yii\web\HttpException(404, 'The requested page does not exist.');
38
        }
39
40
        return $this->controller->render($this->view ?: $this->id, [
41
            'model' => $model,
42
        ]);
43
    }
44
}
45