Completed
Push — master ( fa7b60...6c1318 )
by Mahmoud
03:02
created

Controller   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 70
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 7

Importance

Changes 0
Metric Value
wmc 8
c 0
b 0
f 0
lcom 0
cbo 7
dl 0
loc 70
rs 10

8 Methods

Rating   Name   Duplication   Size   Complexity  
A listAllPermissions() 0 6 1
A getPermission() 0 6 1
A listAllRoles() 0 6 1
A getRole() 0 6 1
A assignUserToRole() 0 4 1
A attachPermissionToRole() 0 4 1
A createRole() 0 4 1
A createPermission() 0 4 1
1
<?php
2
3
namespace App\Containers\Authorization\UI\API\Controllers;
4
5
use App\Containers\Authorization\Actions\ListAllPermissionsAction;
6
use App\Containers\Authorization\Actions\GetPermissionAction;
7
use App\Containers\Authorization\Actions\GetRoleAction;
8
use App\Containers\Authorization\Actions\ListAllRolesAction;
9
use App\Containers\Authorization\UI\API\Requests\GetPermissionRequest;
10
use App\Containers\Authorization\UI\API\Requests\GetRoleRequest;
11
use App\Containers\Authorization\UI\API\Requests\ListAllPermissionsRequest;
12
use App\Containers\Authorization\UI\API\Requests\ListAllRolesRequest;
13
use App\Containers\Authorization\UI\API\Transformers\PermissionTransformer;
14
use App\Containers\Authorization\UI\API\Transformers\RoleTransformer;
15
use App\Containers\Authorization\UI\API\Transformers\UserTransformer;
16
use App\Port\Controller\Abstracts\PortApiController;
17
18
/**
19
 * Class Controller.
20
 *
21
 * @author Mahmoud Zalt <[email protected]>
22
 */
23
class Controller extends PortApiController
24
{
25
26
    /**
27
     * @param \App\Containers\Authorization\UI\API\Requests\ListAllPermissionsRequest $request
28
     * @param \App\Containers\Authorization\Actions\ListAllPermissionsAction           $action
29
     */
30
    public function listAllPermissions(ListAllPermissionsRequest $request, ListAllPermissionsAction $action)
31
    {
32
        $permissions = $action->run();
33
34
        return $this->response->collection($permissions, new PermissionTransformer());
35
    }
36
37
    /**
38
     * @param \App\Containers\Authorization\UI\API\Requests\GetPermissionRequest $request
39
     * @param \App\Containers\Authorization\Actions\GetPermissionAction          $action
40
     */
41
    public function getPermission(GetPermissionRequest $request, GetPermissionAction $action)
42
    {
43
        $permission = $action->run($request->name);
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<App\Containers\Au...s\GetPermissionRequest>. 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...
44
45
        return $this->response->item($permission, new PermissionTransformer());
46
    }
47
48
    /**
49
     * @param \App\Containers\Authorization\UI\API\Requests\ListAllRolesRequest $request
50
     * @param \App\Containers\Authorization\Actions\ListAllRolesAction          $action
51
     *
52
     * @return  \Dingo\Api\Http\Response
53
     */
54
    public function listAllRoles(ListAllRolesRequest $request, ListAllRolesAction $action)
55
    {
56
        $roles = $action->run();
57
58
        return $this->response->collection($roles, new RoleTransformer());
59
    }
60
61
    /**
62
     * @param \App\Containers\Authorization\UI\API\Requests\GetRoleRequest $request
63
     * @param \App\Containers\Authorization\Actions\GetRoleAction          $action
64
     */
65
    public function getRole(GetRoleRequest $request, GetRoleAction $action)
66
    {
67
        $role = $action->run($request->name);
0 ignored issues
show
Documentation introduced by
The property name does not exist on object<App\Containers\Au...equests\GetRoleRequest>. 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...
68
69
        return $this->response->item($role, new RoleTransformer());
70
    }
71
72
    public function assignUserToRole()
73
    {
74
75
    }
76
77
    public function attachPermissionToRole()
78
    {
79
80
    }
81
82
    public function createRole()
83
    {
84
85
    }
86
87
    public function createPermission()
88
    {
89
90
    }
91
92
}
93