Completed
Push — master ( 874c42...3f0650 )
by Ryan
02:09
created

BuildCompleteResetForm   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A handle() 0 16 1
1
<?php namespace Anomaly\UsersModule\User\Command;
2
3
use Anomaly\Streams\Platform\Addon\Plugin\PluginForm;
4
use Anomaly\Streams\Platform\Support\Decorator;
5
use Anomaly\UsersModule\User\Reset\CompleteResetFormBuilder;
6
use Illuminate\Contracts\Bus\SelfHandling;
7
use Illuminate\Contracts\Encryption\Encrypter;
8
use Illuminate\Http\Request;
9
10
/**
11
 * Class BuildCompleteResetForm
12
 *
13
 * @link          http://anomaly.is/streams-platform
14
 * @author        AnomalyLabs, Inc. <[email protected]>
15
 * @author        Ryan Thompson <[email protected]>
16
 * @package       Anomaly\UsersModule\User\Command
17
 */
18
class BuildCompleteResetForm implements SelfHandling
19
{
20
21
    /**
22
     * The form parameters.
23
     *
24
     * @var array
25
     */
26
    protected $parameters;
27
28
    /**
29
     * Create a new BuildCompleteResetForm instance.
30
     *
31
     * @param array $parameters
32
     */
33
    public function __construct(array $parameters = [])
34
    {
35
        $this->parameters = $parameters;
36
    }
37
38
    /**
39
     * Handle the command.
40
     *
41
     * @param PluginForm $form
42
     * @param Request    $request
43
     * @param Encrypter  $encrypter
44
     * @param Decorator  $decorator
45
     * @return \Anomaly\Streams\Platform\Ui\Form\FormBuilder
46
     */
47
    public function handle(PluginForm $form, Request $request, Encrypter $encrypter, Decorator $decorator)
48
    {
49
        $code  = $encrypter->decrypt($request->get('code'));
50
        $email = $encrypter->decrypt($request->get('email'));
51
52
        $parameters = array_merge_recursive(
53
            $this->parameters,
54
            [
55
                'code'    => $code,
56
                'email'   => $email,
57
                'builder' => CompleteResetFormBuilder::class
58
            ]
59
        );
60
61
        return $decorator->decorate($form->make($parameters)->getForm());
62
    }
63
}
64