Completed
Push — master ( effffd...96380e )
by Mahmoud
03:38
created

Controller::showDashboardPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace App\Containers\Authentication\UI\WEB\Controllers;
4
5
use App\Containers\Authentication\Actions\WebAdminLoginAction;
6
use App\Containers\Authentication\Actions\WebLogoutAction;
7
use App\Containers\Authentication\UI\WEB\Requests\LoginRequest;
8
use App\Port\Controller\Abstracts\PortWebController;
9
10
/**
11
 * Class Controller
12
 *
13
 * @author  Mahmoud Zalt  <[email protected]>
14
 */
15
class Controller extends PortWebController
16
{
17
18
    /**
19
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
20
     */
21
    public function showLoginPage()
22
    {
23
        return view('login');
24
    }
25
26
    /**
27
     * @param \App\Containers\Authentication\UI\WEB\Requests\LoginRequest $request
28
     * @param \App\Containers\Authentication\Actions\WebAdminLoginAction  $action
29
     *
30
     * @return  $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
31
     */
32
    public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action)
33
    {
34
        $result = $action->run($request->email, $request->password, $request->remember_me);
0 ignored issues
show
Documentation introduced by
The property email does not exist on object<App\Containers\Au...\Requests\LoginRequest>. 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...
Documentation introduced by
The property password does not exist on object<App\Containers\Au...\Requests\LoginRequest>. 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...
Documentation introduced by
The property remember_me does not exist on object<App\Containers\Au...\Requests\LoginRequest>. 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...
35
36
        if (is_array($result)) {
37
            return view('login')->with($result);
0 ignored issues
show
Bug introduced by
The method with does only exist in Illuminate\View\View, but not in Illuminate\Contracts\View\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...
38
        }
39
40
        return view('dashboard');
41
    }
42
43
    /**
44
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
45
     */
46
    public function showDashboardPage()
47
    {
48
        return view('dashboard');
49
    }
50
51
    /**
52
     * @param \App\Containers\Authentication\Actions\WebLogoutAction $action
53
     *
54
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
55
     */
56
    public function logoutAdmin(WebLogoutAction $action)
57
    {
58
        $action->run();
59
60
        return view('login');
61
    }
62
63
64
}
65