Passed
Push — 5.0.0 ( f10804...44b42e )
by Fèvre
15:04 queued 07:40
created

EmailController::update()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 9
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 14
rs 9.9666
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Xetaravel\Http\Controllers\User;
6
7
use Illuminate\Http\RedirectResponse;
8
use Illuminate\Support\Facades\Auth;
9
use Xetaravel\Http\Controllers\Controller;
10
use Xetaravel\Http\Requests\User\UpdateEmailRequest;
11
12
class EmailController extends Controller
13
{
14
    /**
15
     * Updates the authenticated user's email.
16
     *
17
     * @param UpdateEmailRequest $request
18
     *
19
     * @return RedirectResponse
20
     */
21
    public function update(UpdateEmailRequest $request): RedirectResponse
22
    {
23
        $user = Auth::user();
24
        $user->email = $request->input('email');
0 ignored issues
show
Bug introduced by
Accessing email on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
25
26
        if ($user->save()) {
27
            return redirect()
28
                ->route('user.setting.index')
0 ignored issues
show
Bug introduced by
The method route() does not exist on Illuminate\Routing\Redirector. ( Ignorable by Annotation )

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

28
                ->/** @scrutinizer ignore-call */ route('user.setting.index')

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
29
                ->success('Your E-mail has been updated successfully !');
30
        }
31
32
        return redirect()
33
            ->route('user.setting.index')
34
            ->error('An error occurred while saving your E-mail!');
35
    }
36
}
37