Completed
Push — master ( bcfc51...2533f4 )
by David
01:24 queued 11s
created

HotelController::generateSSO()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Torralbodavid\DuckFunkCore\Http\Controllers\Pages;
4
5
use Illuminate\Support\Str;
6
use Torralbodavid\DuckFunkCore\Http\Traits\RCONConnection;
7
8
class HotelController extends Controller
9
{
10
    use RCONConnection;
11
12
    private function generateSSO()
13
    {
14
        $setSSO = auth()->user();
0 ignored issues
show
Bug introduced by
The method user does only exist in Illuminate\Contracts\Auth\Guard, but not in Illuminate\Contracts\Auth\Factory.

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...
15
        $setSSO->auth_ticket = 'DuckFunk-'.Str::random(25).'-SSO';
16
        $setSSO->save();
17
18
        return $setSSO->auth_ticket;
19
    }
20
21
    protected function getData(): array
22
    {
23
        return [
24
            'sso' => $this->generateSSO(),
25
        ];
26
    }
27
}
28