Completed
Push — master ( a8b6d8...ab125f )
by Ryan
02:01
created

PermissionFormHandler   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 20
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 20
loc 20
wmc 1
lcom 0
cbo 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A handle() 9 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Anomaly\UsersModule\User\Permission;
2
3
use Anomaly\Streams\Platform\Model\EloquentModel;
4
use Anomaly\UsersModule\User\Contract\UserInterface;
5
use Anomaly\UsersModule\User\Contract\UserRepositoryInterface;
6
use Illuminate\Routing\Redirector;
7
8
/**
9
 * Class PermissionFormHandler
10
 *
11
 * @link          http://anomaly.is/streams-platform
12
 * @author        AnomalyLabs, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 * @package       Anomaly\UsersModule\User\Permission
15
 */
16 View Code Duplication
class PermissionFormHandler
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
19
    /**
20
     * Handle the form.
21
     *
22
     * @param PermissionFormBuilder   $builder
23
     * @param UserRepositoryInterface $users
24
     * @param Redirector              $redirect
25
     */
26
    public function handle(PermissionFormBuilder $builder, UserRepositoryInterface $users, Redirector $redirect)
27
    {
28
        /* @var UserInterface|EloquentModel $user */
29
        $user = $builder->getEntry();
30
31
        $users->save($user->setAttribute('permissions', array_filter(array_flatten($builder->getFormInput()))));
32
33
        $builder->setFormResponse($redirect->refresh());
34
    }
35
}
36