LatestAction   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 4
dl 0
loc 11
ccs 0
cts 8
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A run() 0 8 2
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