LatestAction::run()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 0
crap 6
1
<?php
2
3
namespace zacksleo\yii2\romrelease\actions;
4
5
use yii\base\Action;
6
use zacksleo\yii2\romrelease\models\RomRelease;
7
use yii\web\NotFoundHttpException;
8
9
class LatestAction extends Action
10
{
11
    public function run()
12
    {
13
        $model = RomRelease::find()->where(['status' => RomRelease::STATUS_PUBLISHED])->orderBy('updated_at DESC')->one();
14
        if (empty($model)) {
15
            throw new NotFoundHttpException('暂无新的更新');
16
        }
17
        return $model;
18
    }
19
}
20