Code Duplication    Length = 13-14 lines in 2 locations

src/FormElement.php 1 location

@@ 190-203 (lines=14) @@
187
        }
188
    }
189
190
    protected function setClass()
191
    {
192
        // Default class applied to all form elements (Eg 'form-control' for Bootstrap)
193
        $this->class[] = config('blade-form-components.styles.field.input');
194
        
195
        // Attach the error class if an error is displayed against this field
196
        $errors = session()->get('errors', app(ViewErrorBag::class));
197
        if ($errors->has($this->name)) {
198
            $this->class[] = config('blade-form-components.styles.field.error');
199
        }
200
201
        // Attach other user-defined classes
202
203
    }
204
205
    public function glueAttributes()
206
    {

src/FormElements/Checkbox.php 1 location

@@ 41-53 (lines=13) @@
38
        $this->value = 1;
39
    }
40
41
    protected function addClasses()
42
    {
43
        // Specific to Bootstrap, will need to abstract it
44
        $this->class[] = 'custom-control-input';
45
        $this->labelClass[] = 'custom-control-label';
46
47
        // Attach the error class if an error is displayed against this field
48
        $errors = session()->get('errors', app(ViewErrorBag::class));
49
        if ($errors->has($this->name)) {
50
            $this->labelClass[] = config('blade-form-components.styles.field.error');
51
        }
52
53
    }
54
}