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

Test Failed
Push — development ( a51bef...1aad8e )
by José
08:14
created

InvitesController::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
3
namespace DoeSangue\Http\Controllers\API\V1;
4
5
use Illuminate\Http\Request;
6
use DoeSangue\Http\Controllers\Controller;
7
use Tymon\JWTAuth\Facades\JWTAuth;
8
use DoeSangue\Repositories\Invites;
9
use DoeSangue\Models\Invite;
10
use Hash;
11
12
class InvitesController extends Controller
13
{
14
    public function __construct()
15
    {
16
        $this->middleware('jwt.auth', [ 'except' => [ 'invite' ] ]);
17
    }
18
19
    public function create(Request $request)
20
    {
21
        // Determines the user/owner of invite.
22
        $user = JWTAuth::parseToken()->authenticate();
23
24
        $invite = new Invite();
25
        $invite->invite_code = Hash::make($request['invite_code']);
0 ignored issues
show
Documentation introduced by
The property invite_code does not exist on object<DoeSangue\Models\Invite>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
26
        $invite->user_id = $user->id;
0 ignored issues
show
Documentation introduced by
The property user_id does not exist on object<DoeSangue\Models\Invite>. Since you implemented __set, maybe consider adding a @property annotation.

Since your code implements the magic setter _set, this function will be called for any write access on an undefined variable. You can add the @property annotation to your class or interface to document the existence of this variable.

<?php

/**
 * @property int $x
 * @property int $y
 * @property string $text
 */
class MyLabel
{
    private $properties;

    private $allowedProperties = array('x', 'y', 'text');

    public function __get($name)
    {
        if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
            return $properties[$name];
        } else {
            return null;
        }
    }

    public function __set($name, $value)
    {
        if (in_array($name, $this->allowedProperties)) {
            $properties[$name] = $value;
        } else {
            throw new \LogicException("Property $name is not defined.");
        }
    }

}

Since the property has write access only, you can use the @property-write annotation instead.

Of course, you may also just have mistyped another name, in which case you should fix the error.

See also the PhpDoc documentation for @property.

Loading history...
27
        $invite->save();
28
29
        return response()->json(
30
            [
31
            'status_code' => 201,
32
            'message' => 'Invite created!'
33
            ], 201
34
        );
35
    }
36
37
    public function show($id)
38
    {
39
        $invite = Invite::find($id);
40
41
        return response()->json($invite, 200);
42
    }
43
44
}
45