Scrutinizer GitHub App not installed

We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.

Install GitHub App

AccountController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 37
ccs 0
cts 17
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A userInfo() 0 24 2
A updateProfile() 0 4 1
1
<?php
2
3
namespace DoeSangue\Http\Controllers\API\V1\User;
4
5
use JWTAuth;
6
use Illuminate\Http\Request;
7
use DoeSangue\Http\Controllers\Controller;
8
9
class AccountController extends Controller
10
{
11
    /**
12
     * Get Logged in User information.
13
     *
14
     * @return \Illuminate\Http\JsonResponse
15
     */
16
    public function userInfo()
17
    {
18
        $user = JWTAuth::parseToken()->authenticate();
19
20
        // If the token is invalid
21
        if (!$user) {
22
            return response()->json([ 'invalid_user' ], 401);
0 ignored issues
show
Bug introduced by
The method json does only exist in Illuminate\Contracts\Routing\ResponseFactory, but not in Illuminate\Http\Response.

It seems like the method you are trying to call exists only in some of the possible types.

Let’s take a look at an example:

class A
{
    public function foo() { }
}

class B extends A
{
    public function bar() { }
}

/**
 * @param A|B $x
 */
function someFunction($x)
{
    $x->foo(); // This call is fine as the method exists in A and B.
    $x->bar(); // This method only exists in B and might cause an error.
}

Available Fixes

  1. Add an additional type-check:

    /**
     * @param A|B $x
     */
    function someFunction($x)
    {
        $x->foo();
    
        if ($x instanceof B) {
            $x->bar();
        }
    }
    
  2. Only allow a single type to be passed if the variable comes from a parameter:

    function someFunction(B $x) { /** ... */ }
    
Loading history...
23
        }
24
        // Return the user data in json.
25
        return response()->json(
26
            [
27
            'first_name' =>   $user->first_name,
28
            'last_name'  =>   $user->last_name,
29
            'email'      =>   $user->email,
30
            'username'   =>   $user->username,
31
            'blood_type' =>   $user->donor->bloodType->code,
32
            'avatar'     =>   '', //$user->avatar,
33
            'birthdate'  =>   $user->birthdate,
34
            'phone'      =>   $user->phone,
35
            'bio'        =>   $user->bio
36
            ], 200
37
        );
38
39
    }
40
41
    public function updateProfile(Request $data)
0 ignored issues
show
Unused Code introduced by
The parameter $data is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
42
    {
43
        //
44
    }
45
}
46