PermissionFormHandler::handle()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 4

Duplication

Lines 9
Ratio 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
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://pyrocms.com/
12
 * @author        PyroCMS, Inc. <[email protected]>
13
 * @author        Ryan Thompson <[email protected]>
14
 */
15 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...
16
{
17
18
    /**
19
     * Handle the form.
20
     *
21
     * @param PermissionFormBuilder   $builder
22
     * @param UserRepositoryInterface $users
23
     * @param Redirector              $redirect
24
     */
25
    public function handle(PermissionFormBuilder $builder, UserRepositoryInterface $users, Redirector $redirect)
26
    {
27
        /* @var UserInterface|EloquentModel $user */
28
        $user = $builder->getEntry();
29
30
        $users->save($user->setAttribute('permissions', array_filter(array_flatten($builder->getFormInput()))));
31
32
        $builder->setFormResponse($redirect->refresh());
33
    }
34
}
35