GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( c27c09...a845ba )
by Brett
04:59
created

MailController   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 66
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 6

Test Coverage

Coverage 71.43%

Importance

Changes 1
Bugs 1 Features 0
Metric Value
wmc 7
c 1
b 1
f 0
lcom 1
cbo 6
dl 0
loc 66
ccs 20
cts 28
cp 0.7143
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A actionIndex() 0 10 1
A actionView() 0 10 2
A actionViewHtml() 0 11 2
A actionDownload() 0 8 2
1
<?php
2
3
namespace bedezign\yii2\audit\controllers;
4
5
use bedezign\yii2\audit\components\Helper;
6
use bedezign\yii2\audit\components\web\Controller;
7
use bedezign\yii2\audit\models\AuditMail;
8
use bedezign\yii2\audit\models\AuditMailSearch;
9
use Yii;
10
use yii\web\NotFoundHttpException;
11
12
/**
13
 * MailController
14
 * @package bedezign\yii2\audit\controllers
15
 */
16
class MailController extends Controller
17
{
18
    /**
19
     * Lists all AuditMail models.
20
     * @return mixed
21
     */
22 2
    public function actionIndex()
23
    {
24 2
        $searchModel = new AuditMailSearch;
25 2
        $dataProvider = $searchModel->search(Yii::$app->request->get());
26
27 2
        return $this->render('index', [
28 2
            'dataProvider' => $dataProvider,
29 2
            'searchModel' => $searchModel,
30 2
        ]);
31
    }
32
33
    /**
34
     * Displays a single AuditMail model.
35
     * @param integer $id
36
     * @return mixed
37
     * @throws NotFoundHttpException
38
     */
39 1
    public function actionView($id)
40
    {
41 1
        $model = AuditMail::findOne($id);
42 1
        if (!$model) {
43 1
            throw new NotFoundHttpException('The requested mail does not exist.');
44
        }
45 1
        return $this->render('view', [
46 1
            'model' => $model,
47 1
        ]);
48
    }
49
50
    /**
51
     * Displays a single AuditMail model's HTML.
52
     * @param integer $id
53
     * @return mixed
54
     * @throws NotFoundHttpException
55
     */
56
    public function actionViewHtml($id)
57
    {
58
        $model = AuditMail::findOne($id);
59
        if (!$model) {
60
            throw new NotFoundHttpException('The requested mail does not exist.');
61
        }
62
        $this->layout = false;
63
        return $this->render('view-html', [
64
            'model' => $model,
65
        ]);
66
    }
67
68
    /**
69
     * Download an AuditMail file as eml.
70
     * @param $id
71
     * @throws NotFoundHttpException
72
     */
73 3
    public function actionDownload($id)
74
    {
75 1
        $model = AuditMail::findOne($id);
76 1
        if (!$model) {
77 1
            throw new NotFoundHttpException('The requested mail does not exist.');
78
        }
79 1
        Yii::$app->response->sendContentAsFile(Helper::uncompress($model->data), $model->id . '.eml');
80 3
    }
81
}
82