Passed
Push — master ( 8f6522...eef865 )
by Florian
06:34
created

OldValueSupportTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 3
dl 0
loc 22
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeItemValue() 0 3 2
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\View\Components\Form\Traits;
4
5
trait OldValueSupportTrait
6
{
7
    /**
8
     * Enable the retrievement of the submitted value in case of validation
9
     * errors. This submitted value may be automatically shown when there is a
10
     * validation error.
11
     *
12
     * @var bool
13
     */
14
    protected $enableOldSupport;
15
16
    /**
17
     * Make the value attribute for an input item, with auto lookup for a
18
     * submitted value in case of validation errors.
19
     *
20
     * @param  string  $errorKey  The key name to lookup for validation errors
21
     * @param  mixed  $default  The default value for the input element
22
     * @return mixed
23
     */
24 2
    public function makeItemValue($errorKey, $default = null)
25
    {
26 2
        return $this->enableOldSupport ? old($errorKey, $default) : $default;
27
    }
28
}
29