TrailController::actionIndex()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 10
ccs 7
cts 7
cp 1
crap 1
rs 9.9332
c 0
b 0
f 0
1
<?php
2
3
namespace bedezign\yii2\audit\controllers;
4
5
use bedezign\yii2\audit\components\web\Controller;
6
use bedezign\yii2\audit\models\AuditTrail;
7
use bedezign\yii2\audit\models\AuditTrailSearch;
8
use Yii;
9
use yii\web\NotFoundHttpException;
10
11
/**
12
 * TrailController
13
 * @package bedezign\yii2\audit\controllers
14
 */
15
class TrailController extends Controller
16
{
17
    /**
18
     * Lists all AuditTrail models.
19
     * @return mixed
20
     */
21 6
    public function actionIndex()
22
    {
23 6
        $searchModel = new AuditTrailSearch;
24 6
        $dataProvider = $searchModel->search(Yii::$app->request->get());
25
26 6
        return $this->render('index', [
27 6
            'dataProvider' => $dataProvider,
28 6
            'searchModel'  => $searchModel,
29 6
        ]);
30
    }
31
32
    /**
33
     * Displays a single AuditTrail model.
34
     * @param integer $id
35
     * @return mixed
36
     * @throws NotFoundHttpException
37
     */
38 3
    public function actionView($id)
39
    {
40 3
        $model = AuditTrail::findOne($id);
41 3
        if (!$model) {
42 3
            throw new NotFoundHttpException('The requested trail does not exist.');
43
        }
44 3
        return $this->render('view', [
45 3
            'model' => $model,
46 3
        ]);
47
    }
48
}
49