Code Duplication    Length = 30-31 lines in 2 locations

src/Ui/Form/Command/FlashFormErrors.php 1 location

@@ 16-45 (lines=30) @@
13
 * @author        Ryan Thompson <[email protected]>
14
 * @package       Anomaly\Streams\Platform\Ui\Form\Command
15
 */
16
class FlashFormErrors implements SelfHandling
17
{
18
19
    /**
20
     * The form builder.
21
     *
22
     * @var FormBuilder
23
     */
24
    protected $builder;
25
26
    /**
27
     * Create a new FlashFormErrors instance.
28
     *
29
     * @param FormBuilder $builder
30
     */
31
    public function __construct(FormBuilder $builder)
32
    {
33
        $this->builder = $builder;
34
    }
35
36
    /**
37
     * Handle the event.
38
     *
39
     * @param Store $session
40
     */
41
    public function handle(Store $session)
42
    {
43
        $session->flash($this->builder->getOption('prefix') . 'errors', $this->builder->getFormErrors());
44
    }
45
}
46

src/Ui/Form/Command/LoadFormErrors.php 1 location

@@ 17-47 (lines=31) @@
14
 * @author        Ryan Thompson <[email protected]>
15
 * @package       Anomaly\Streams\Platform\Ui\Form\Command
16
 */
17
class LoadFormErrors implements SelfHandling
18
{
19
20
    /**
21
     * The form builder.
22
     *
23
     * @var FormBuilder
24
     */
25
    protected $builder;
26
27
    /**
28
     * Create a new LoadFormErrors instance.
29
     *
30
     * @param FormBuilder $builder
31
     */
32
    public function __construct(FormBuilder $builder)
33
    {
34
        $this->builder = $builder;
35
    }
36
37
    /**
38
     * Handle the event.
39
     */
40
    public function handle(Store $session)
41
    {
42
        /* @var MessageBag $errors */
43
        if ($errors = $session->get($this->builder->getOption('prefix') . 'errors')) {
44
            $this->builder->setFormErrors($errors);
45
        }
46
    }
47
}
48