Passed
Pull Request — master (#1012)
by Diego
03:15
created

OldValueSupportTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 25
ccs 0
cts 4
cp 0
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A makeItemValue() 0 7 2
1
<?php
2
3
namespace JeroenNoten\LaravelAdminLte\Components\Form;
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.
18
     *
19
     * @param  string  $errKey  The key name to lookup for validation errors
20
     * @param  mixed  $value  The current value of the item
21
     * @return mixed
22
     */
23
    public function makeItemValue($errorKey, $value = null)
24
    {
25
        if ($this->enableOldSupport) {
26
            $value = old($errorKey, $value);
27
        }
28
29
        return $value;
30
    }
31
}
32