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::actionDownload()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2
Metric Value
dl 0
loc 8
ccs 6
cts 6
cp 1
rs 9.4285
cc 2
eloc 5
nc 2
nop 1
crap 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