Controller   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 5
dl 0
loc 56
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A showLoginPage() 0 4 1
A loginAdmin() 0 14 3
A viewDashboardPage() 0 4 1
A logoutAdmin() 0 6 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\Exceptions\AuthenticationFailedException;
8
use App\Containers\Authentication\UI\WEB\Requests\LoginRequest;
9
use App\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest;
10
use App\Ship\Parents\Controllers\WebController;
11
12
/**
13
 * Class Controller
14
 *
15
 * @author  Mahmoud Zalt  <[email protected]>
16
 */
17
class Controller extends WebController
18
{
19
20
    /**
21
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
22
     */
23
    public function showLoginPage()
24
    {
25
        return view('authentication::login');
26
    }
27
28
    /**
29
     * @param \App\Containers\Authentication\UI\WEB\Requests\LoginRequest $request
30
     * @param \App\Containers\Authentication\Actions\WebAdminLoginAction  $action
31
     *
32
     * @return  $this|\Illuminate\Http\RedirectResponse|\Illuminate\Routing\Redirector
33
     */
34
    public function loginAdmin(LoginRequest $request, WebAdminLoginAction $action)
35
    {
36
        try {
37
            $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...
38
        } catch (AuthenticationFailedException $e) {
39
            return redirect('login')->with('status', $e->getMessage());
40
        }
41
42
        if (is_array($result)) {
43
            return redirect('login')->with($result);
44
        }
45
46
        return redirect('dashboard');
47
    }
48
49
    /**
50
     * @param \App\Containers\Authentication\UI\WEB\Requests\ViewDashboardRequest $request
51
     *
52
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
53
     */
54
    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...
55
    {
56
        return view('authentication::dashboard');
57
    }
58
59
    /**
60
     * @param \App\Containers\Authentication\Actions\WebLogoutAction $action
61
     *
62
     * @return  \Illuminate\Contracts\View\Factory|\Illuminate\View\View
63
     */
64
    public function logoutAdmin(WebLogoutAction $action)
65
    {
66
        $action->run();
67
68
        return redirect('login');
69
    }
70
71
72
}
73