MailController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 3 1
A update() 0 17 1
1
<?php
2
3
namespace App\Http\Controllers\Settings;
4
5
use App\Http\Controllers\Controller;
6
use Brotzka\DotenvEditor\DotenvEditor;
7
use App\Http\Requests\Settings\MailSettingsUpdateRequest;
8
9
/**
10
 * Class MailController.
11
 */
12
class MailController extends Controller
13
{
14
    /**
15
     * @return \Illuminate\Contracts\View\Factory|\Illuminate\View\View
16
     */
17
    public function index()
18
    {
19
        return view('settings.mail');
20
    }
21
22
    /**
23
     * @param MailSettingsUpdateRequest $request
24
     * @return \Illuminate\Http\RedirectResponse
25
     * @throws \Brotzka\DotenvEditor\Exceptions\DotEnvException
26
     */
27
    public function update(MailSettingsUpdateRequest $request)
28
    {
29
        $env = new DotenvEditor;
30
        $env->changeEnv([
31
            'MAIL_DRIVER' => $request->input('MAIL_DRIVER'),
32
            'MAIL_PORT' => $request->input('MAIL_PORT'),
33
            'MAIL_HOST' => $request->input('MAIL_HOST'),
34
            'MAIL_USERNAME' => $request->input('MAIL_USERNAME'),
35
            'MAIL_PASSWORD' => $request->input('MAIL_PASSWORD'),
36
        ]);
37
38
        notify()->flash(trans('general.woohoo'), 'success', [
0 ignored issues
show
Bug introduced by
It seems like trans('general.woohoo') can also be of type array; however, parameter $message of Codecourse\Notify\Notifier::flash() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

38
        notify()->flash(/** @scrutinizer ignore-type */ trans('general.woohoo'), 'success', [
Loading history...
39
            'timer' => 2000,
40
            'text' => trans('general.success.update'),
41
        ]);
42
43
        return redirect()->route('settings.mail');
44
    }
45
}
46