Completed
Push — master ( c5bf06...fa7b60 )
by Mahmoud
02:44
created

Controller::viewDashboardPage()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
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\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest;
9
use App\Port\Controller\Abstracts\PortWebController;
10
11
use App\Containers\Authentication\Exceptions\AuthenticationFailedException;
12
13
/**
14
 * Class Controller
15
 *
16
 * @author  Mahmoud Zalt  <[email protected]>
17
 */
18
class Controller extends PortWebController
19
{
20
21
    /**
22
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
23
     */
24
    public function showLoginPage()
25
    {
26
        return view('login');
27
    }
28
29
    /**
30
     * @param \App\Containers\Authentication\UI\WEB\Requests\LoginRequest $request
31
     * @param \App\Containers\Authentication\Actions\WebAdminLoginAction  $action
32
     *
33
     * @return  $this|\Illuminate\Contracts\View\Factory|\Illuminate\View\View
34
     */
35
    public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action)
36
    {
37
        try {
38
            $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...
39
        } catch (AuthenticationFailedException $e) {
40
            return redirect('/login')->with('status', $e->message);
41
        }
42
43
        if (is_array($result)) {
44
            return redirect('/login')->with($result);
45
        }
46
47
        return redirect('/dashboard');
48
    }
49
50
    /**
51
     * @param \App\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest $request
52
     *
53
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
54
     */
55
    public function viewDashboardPage(ViewDashboardRequest $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...
56
    {
57
        return view('dashboard');
58
    }
59
60
    /**
61
     * @param \App\Containers\Authentication\Actions\WebLogoutAction $action
62
     *
63
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
64
     */
65
    public function logoutAdmin(WebLogoutAction $action)
66
    {
67
        $action->run();
68
69
        return view('login');
70
    }
71
72
73
}
74