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

PermissionFormHandler::handle()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Importance

Changes 5
Bugs 0 Features 0
Metric Value
c 5
b 0
f 0
dl 9
loc 9
rs 9.6666
cc 1
eloc 4
nc 1
nop 3
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