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

Completed
Push — development ( 5ace46...f3dfe7 )
by José
16:05 queued 11:10
created

InvitationRequestsController::checkInvitation()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 2
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
namespace DoeSangue\Http\Controllers\Auth\V1;
4
5
use Illuminate\Http\Request;
6
use DoeSangue\Http\Controllers\Controller;
7
use DoeSangue\Http\Requests\UserInvitationRequest;
8
use Hash, DB;
9
10
class InvitationRequestsController extends Controller
11
{
12
    /**
13
     * Create an invite when user requests from API.
14
     *
15
     * @param UserInvitationRequest $request
16
     * @return void
17
     */
18 1
    public function createInvitation(UserInvitationRequest $request)
19
    {
20
21 1
        $guestExist = DB::table('invitation_requests')
22 1
                     ->where('guest_email', $request['guest_email'])->first();
23
24 1
        if (!$guestExist) {
25
            $guest = [
26 1
                'first_name' => $request->first_name,
0 ignored issues
show
Documentation introduced by
The property first_name does not exist on object<DoeSangue\Http\Re...\UserInvitationRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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 1
                'last_name' => $request->last_name,
0 ignored issues
show
Documentation introduced by
The property last_name does not exist on object<DoeSangue\Http\Re...\UserInvitationRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
28 1
                'guest_email' => $request->guest_email,
0 ignored issues
show
Documentation introduced by
The property guest_email does not exist on object<DoeSangue\Http\Re...\UserInvitationRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
29 1
                'country_id' => $request->country_id,
0 ignored issues
show
Documentation introduced by
The property country_id does not exist on object<DoeSangue\Http\Re...\UserInvitationRequest>. Since you implemented __get, maybe consider adding a @property annotation.

Since your code implements the magic getter _get, this function will be called for any read 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.");
        }
    }

}

If the property has read access only, you can use the @property-read 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...
30 1
                'token' => Hash::make(str_random(60)),
31 1
                'created_at' => \Carbon\Carbon::now(),
32 1
                'updated_at' => \Carbon\Carbon::now()
33
            ];
34
35 1
            DB::table('invitation_requests')->insert($guest);
36
37
            return response()->json([
38
                'message' => 'Urrah! You have been invited. Check you email for more information.'
39
            ], 201);
40
        } else {
41
            return response()->json([
42
                'message' => 'Oops. Looks like you have been invited already. But don\'t scary, we will send you again!'
43
            ], 200);
44
        }
45
46
    }
47
48
    /**
49
     * Check if User was invited before.
50
     *
51
     * @param Request $data
52
     * @return void
53
     */
54
    public function checkInvitation(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...
55
    {}
56
}
57