ClientController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 40
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getUrl() 0 6 1
A showClient() 0 6 1
A getInterstitial() 0 4 1
1
<?php
2
3
namespace App\Http\Controllers;
4
5
use App\Facades\User;
6
use Illuminate\Http\Request;
7
use Illuminate\Http\Response;
8
use Illuminate\Support\Facades\Config;
9
use Laravel\Lumen\Routing\Controller as BaseController;
10
11
/**
12
 * Class ClientController.
13
 */
14
class ClientController extends BaseController
15
{
16
    /**
17
     * Returns the Client URL.
18
     *
19
     * @param Request $request
20
     *
21
     * @return Response
22
     */
23
    public function getUrl(Request $request)
0 ignored issues
show
Unused Code introduced by
The parameter $request 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...
24
    {
25
        $hotelUrl = Config::get('chocolatey.hotelUrl');
26
27
        return response()->json(['clienturl' => "{$hotelUrl}/client/habbo-client"], 200, [], JSON_UNESCAPED_SLASHES);
0 ignored issues
show
Bug introduced by
The method json does only exist in Laravel\Lumen\Http\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...
28
    }
29
30
    /**
31
     * Get Client View.
32
     *
33
     * @return Response
34
     */
35
    public function showClient(): Response
36
    {
37
        User::updateSession(['auth_ticket' => ($userToken = uniqid('HabboWEB', true))]);
38
39
        return response(view('habbo-web-pages.habbo-client', ['token' => $userToken, 'newUser' => in_array('NEW_USER', User::getUser()->traits)]));
40
    }
41
42
    /**
43
     * Get HabboWEB Ads Interstitial.
44
     *
45
     * @param string $interstitialType
46
     *
47
     * @return Response
48
     */
49
    public function getInterstitial(string $interstitialType): Response
0 ignored issues
show
Unused Code introduced by
The parameter $interstitialType 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...
50
    {
51
        return response(view('habbo-web-ads.interstitial'));
52
    }
53
}
54