ChangeUserProfileInfoController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 5
Bugs 1 Features 1
Metric Value
wmc 3
eloc 10
c 5
b 1
f 1
dl 0
loc 30
ccs 0
cts 15
cp 0
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A update() 0 18 2
1
<?php
2
3
namespace MedianetDev\LaravelAuthApi\Http\Controllers;
4
5
use Illuminate\Support\Facades\Auth;
6
use MedianetDev\LaravelAuthApi\Http\Helpers\ApiResponse;
7
use MedianetDev\LaravelAuthApi\Http\Requests\ChangeUserProfileInfoRequest;
8
9
class ChangeUserProfileInfoController extends Controller
10
{
11
    /**
12
     * Create a new controller instance.
13
     *
14
     * @return void
15
     */
16
    public function __construct()
17
    {
18
        $this->middleware('auth:api');
19
    }
20
21
    public function update(ChangeUserProfileInfoRequest $request)
22
    {
23
        //TODO: encapsulate all the responses with ApiRequest
24
        $user = Auth::guard('apiauth')->user();
25
26
        $user->name = $request->name;
0 ignored issues
show
Bug introduced by
Accessing name on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
27
        $user->email = $request->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...
28
29
        if ($user->isDirty('email')) {
30
            // mark the email as not verified yet
31
            $user->email_verified_at = null;
0 ignored issues
show
Bug introduced by
Accessing email_verified_at on the interface Illuminate\Contracts\Auth\Authenticatable suggest that you code against a concrete implementation. How about adding an instanceof check?
Loading history...
32
            // send a verification email
33
            $user->sendEmailVerificationNotification();
34
        }
35
36
        $user->save();
37
38
        return ApiResponse::send(['status' => 'Account updated successfully'], 1, 200, 'Account updated successfully');
39
    }
40
}
41