Completed
Push — master ( e7b79c...402727 )
by Ryan
09:29
created

LoadFormErrors   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A handle() 7 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php namespace Anomaly\Streams\Platform\Ui\Form\Command;
2
3
use Anomaly\Streams\Platform\Addon\FieldType\FieldType;
4
use Anomaly\Streams\Platform\Ui\Form\FormBuilder;
5
use Illuminate\Contracts\Bus\SelfHandling;
6
use Illuminate\Contracts\Support\MessageBag;
7
use Illuminate\Session\Store;
8
9
/**
10
 * Class LoadFormErrors
11
 *
12
 * @link          http://anomaly.is/streams-platform
13
 * @author        AnomalyLabs, Inc. <[email protected]>
14
 * @author        Ryan Thompson <[email protected]>
15
 * @package       Anomaly\Streams\Platform\Ui\Form\Command
16
 */
17 View Code Duplication
class LoadFormErrors implements SelfHandling
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...
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