HandleEmailRegistration::handle()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 5

Duplication

Lines 11
Ratio 100 %

Importance

Changes 0
Metric Value
dl 11
loc 11
c 0
b 0
f 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
1
<?php namespace Anomaly\UsersModule\User\Register\Command;
2
3
use Anomaly\UsersModule\User\UserActivator;
4
use Anomaly\Streams\Platform\Message\MessageBag;
5
use Anomaly\UsersModule\User\Contract\UserInterface;
6
use Anomaly\UsersModule\User\Register\RegisterFormBuilder;
7
8 View Code Duplication
class HandleEmailRegistration
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...
9
{
10
11
    /**
12
     * The form builder.
13
     *
14
     * @var RegisterFormBuilder
15
     */
16
    protected $builder;
17
18
    /**
19
     * Create a new HandleEmailRegistration instance.
20
     *
21
     * @param RegisterFormBuilder $builder
22
     */
23
    public function __construct(RegisterFormBuilder $builder)
24
    {
25
        $this->builder = $builder;
26
    }
27
28
    /**
29
     * Handle the command.
30
     *
31
     * @param UserActivator $activator
32
     * @param MessageBag    $messages
33
     */
34
    public function handle(UserActivator $activator, MessageBag $messages)
35
    {
36
        /* @var UserInterface $user */
37
        $user = $this->builder->getFormEntry();
38
39
        $activator->send($user, $this->builder->getFormOption('activate_redirect', '/'));
40
41
        if (!is_null($message = $this->builder->getFormOption('confirm_message'))) {
42
            $messages->info($message);
43
        }
44
    }
45
}
46